]> git.ipfire.org Git - thirdparty/kmod.git/commitdiff
modprobe: fix leak on error path
authorLucas De Marchi <lucas.demarchi@profusion.mobi>
Thu, 12 Jan 2012 17:36:54 +0000 (15:36 -0200)
committerLucas De Marchi <lucas.demarchi@profusion.mobi>
Thu, 12 Jan 2012 17:37:57 +0000 (15:37 -0200)
tools/kmod-modprobe.c

index ae6fc91d675a66c2f0f052a82bab39aeba63a03e..33510f015797bf385ccd0991babe46b1f74f85d6 100644 (file)
@@ -370,16 +370,21 @@ static int rmmod_do_module(struct kmod_module *mod, bool do_dependencies)
 
                if (state < 0) {
                        LOG ("Module %s not found.\n", modname);
-                       return -ENOENT;
+                       err = -ENOENT;
+                       goto error;
                } else if (state == KMOD_MODULE_BUILTIN) {
                        LOG("Module %s is builtin.\n", modname);
-                       return -ENOENT;
+                       err = -ENOENT;
+                       goto error;
                } else if (state != KMOD_MODULE_LIVE) {
                        if (first_time) {
                                LOG("Module %s is not in kernel.\n", modname);
-                               return -ENOENT;
-                       } else
-                               return 0;
+                               err = -ENOENT;
+                               goto error;
+                       } else {
+                               err = 0;
+                               goto error;
+                       }
                }
        }