]> pilppa.com Git - linux-2.6-omap-h63xx.git/commitdiff
driver core: refcounting fix
authorMike Galbraith <efault@gmx.de>
Wed, 21 Feb 2007 20:45:35 +0000 (12:45 -0800)
committerGreg Kroah-Hartman <gregkh@suse.de>
Fri, 23 Feb 2007 22:52:09 +0000 (14:52 -0800)
Fix a reference counting bug exposed by commit
725522b5453dd680412f2b6463a988e4fd148757.  If driver.mod_name exists, we
take a reference in module_add_driver(), and never release it.  Undo that
reference in module_remove_driver().

Signed-off-by: Mike Galbraith <efault@gmx.de>
Cc: Kay Sievers <kay.sievers@vrfy.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
kernel/module.c

index 8c25b1a04fa6d8f3dbbda8f57a045cc2d32714bd..1ecf0810638192c3df6dfab249886ee5559dfa80 100644 (file)
@@ -2425,6 +2425,12 @@ void module_remove_driver(struct device_driver *drv)
                        kfree(driver_name);
                }
        }
+       /*
+        * Undo the additional reference we added in module_add_driver()
+        * via kset_find_obj()
+        */
+       if (drv->mod_name)
+               kobject_put(&drv->kobj);
 }
 EXPORT_SYMBOL(module_remove_driver);
 #endif