From: Tobias Stoeckmann Date: Tue, 5 Nov 2024 16:58:15 +0000 (+0100) Subject: depmod: Release memory on error paths X-Git-Tag: v34~97 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=da0ee2217d8c95974da9c7ab7f8a49cf93eef03d;p=thirdparty%2Fkmod.git 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 Link: https://github.com/kmod-project/kmod/pull/228 Signed-off-by: Lucas De Marchi --- diff --git a/tools/depmod.c b/tools/depmod.c index 999b5b5a..dc4b8a2f 100644 --- a/tools/depmod.c +++ b/tools/depmod.c @@ -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;