From da0ee2217d8c95974da9c7ab7f8a49cf93eef03d Mon Sep 17 00:00:00 2001 From: Tobias Stoeckmann Date: Tue, 5 Nov 2024 17:58:15 +0100 Subject: [PATCH] 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 --- tools/depmod.c | 2 ++ 1 file changed, 2 insertions(+) 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; -- 2.47.2