diff --git a/src/01-skeleton/s02e04-dynamic_allocation.c b/src/01-skeleton/s02e04-dynamic_allocation.c index f8591b8..65eaac0 100644 --- a/src/01-skeleton/s02e04-dynamic_allocation.c +++ b/src/01-skeleton/s02e04-dynamic_allocation.c @@ -49,7 +49,9 @@ void dynAlloc_exit(void) { e = list_entry(list_unique_elements.next, struct element, node); pr_info ("delete element %d: %s\n", e->unique_number, e->text); list_del(&e->node); - kfree(e); + if (e != 0) { + kfree(e); + } } pr_info("Memory allocated for dynamic allocation and linked list freed\n");