]> git.ipfire.org Git - thirdparty/kmod.git/commitdiff
Ignore "already loaded" error in module_probe_insert_module()
authorLucas De Marchi <lucas.demarchi@profusion.mobi>
Fri, 30 Dec 2011 16:15:40 +0000 (14:15 -0200)
committerLucas De Marchi <lucas.demarchi@profusion.mobi>
Fri, 30 Dec 2011 16:16:15 +0000 (14:16 -0200)
It also fixes a leak in the error path.

libkmod/libkmod-module.c

index 0390250d0af50747ecbf861cf9bf0efdd9681145..8e4a26d68c8916e3471ef32e0a2285d824e050f9 100644 (file)
@@ -1015,8 +1015,14 @@ int module_probe_insert_module(struct kmod_module *mod,
 
        free(options);
 
-       if (err < 0 && (flags & KMOD_PROBE_STOP_ON_FAILURE))
-               return err;
+       /*
+        * Ignore "already loaded" error. We need to check here because of
+        * race conditions. We checked first if module was already loaded but
+        * it may have been loaded between the check and the moment we try to
+        * insert it.
+        */
+       if (err < 0 && err != -EEXIST && (flags & KMOD_PROBE_STOP_ON_FAILURE))
+               goto finish;
 
        err = module_do_insmod_dep(post, flags, cb, rec, reccount);