From a0b6feff3b0e8ef56470f20e30f93d012dffc290 Mon Sep 17 00:00:00 2001 From: Alexander Couzens Date: Sun, 11 Jun 2017 12:20:59 +0200 Subject: [PATCH] kmodloader: insmod: fix a memoryleak in error case Found-by: Coverity Scan #1412469 Signed-off-by: Alexander Couzens --- kmodloader.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/kmodloader.c b/kmodloader.c index 9aba523..3b7ec8b 100644 --- a/kmodloader.c +++ b/kmodloader.c @@ -691,22 +691,24 @@ static int main_insmod(int argc, char **argv) if (init_module_folders()) { fprintf(stderr, "Failed to find the folder holding the modules\n"); - return -1; + ret = -1; + goto err; } if (get_module_path(argv[1])) { name = argv[1]; } else if (!get_module_path(name)) { fprintf(stderr, "Failed to find %s. Maybe it is a built in module ?\n", name); - return -1; + ret = -1; + goto err; } ret = insert_module(get_module_path(name), options); - free(options); - if (ret) ULOG_ERR("failed to insert %s\n", get_module_path(name)); +err: + free(options); return ret; } -- 2.25.1