kmodloader: insmod: fix a memoryleak in error case
authorAlexander Couzens <lynxis@fe80.eu>
Sun, 11 Jun 2017 10:20:59 +0000 (12:20 +0200)
committerAlexander Couzens <lynxis@fe80.eu>
Sun, 11 Jun 2017 12:30:20 +0000 (14:30 +0200)
Found-by: Coverity Scan #1412469
Signed-off-by: Alexander Couzens <lynxis@fe80.eu>
kmodloader.c

index 9aba52392d1e06fe69aee6f3101ce4ed78aee28e..3b7ec8b0f59cdc09180fad76fd978e4abd689072 100644 (file)
@@ -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;
 }