depmod: Release memory on error paths

If a list node could not be added, release already allocated data which
was supposed to end up in list.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
Link: https://github.com/kmod-project/kmod/pull/228
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
This commit is contained in:
Tobias Stoeckmann 2024-11-05 17:58:15 +01:00 committed by Lucas De Marchi
parent 63aec6095b
commit da0ee2217d

View File

@ -1867,6 +1867,7 @@ static int depmod_report_cycles_from_root(struct depmod *depmod, struct mod *roo
l = kmod_list_append(free_list, root);
if (l == NULL) {
ERR("No memory to report cycles\n");
free(root);
goto out;
}
free_list = l;
@ -1922,6 +1923,7 @@ static int depmod_report_cycles_from_root(struct depmod *depmod, struct mod *roo
l = kmod_list_append(free_list, v);
if (l == NULL) {
ERR("No memory to report cycles\n");
free(v);
goto out;
}
free_list = l;