memory handling improvement

This commit is contained in:
suvendhu 2023-06-14 14:51:26 +05:30
parent 4775925cb4
commit ac7410a726

View file

@ -677,8 +677,10 @@ void icwmp_free(void *m)
return; return;
struct cwmp_mem *rm; struct cwmp_mem *rm;
rm = container_of(m, struct cwmp_mem, mem); rm = container_of(m, struct cwmp_mem, mem);
list_del(&rm->list); if (rm != NULL) {
free(rm); list_del(&rm->list);
free(rm);
}
} }
void icwmp_cleanmem() void icwmp_cleanmem()
@ -686,8 +688,10 @@ void icwmp_cleanmem()
struct cwmp_mem *mem; struct cwmp_mem *mem;
while (cwmp_memory_list.next != &cwmp_memory_list) { while (cwmp_memory_list.next != &cwmp_memory_list) {
mem = list_entry(cwmp_memory_list.next, struct cwmp_mem, list); mem = list_entry(cwmp_memory_list.next, struct cwmp_mem, list);
list_del(&mem->list); if (mem != NULL) {
free(mem); list_del(&mem->list);
free(mem);
}
} }
} }