From: Mike Galbraith Date: Wed, 21 Feb 2007 20:45:35 +0000 (-0800) Subject: driver core: refcounting fix X-Git-Tag: v2.6.21-rc2~44^2~7 X-Git-Url: http://pilppa.com/gitweb/?a=commitdiff_plain;h=63ce18cfe685115ff8d341bae4c9204a79043cf0;p=linux-2.6-omap-h63xx.git driver core: refcounting fix 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 Cc: Kay Sievers Signed-off-by: Andrew Morton Signed-off-by: Greg Kroah-Hartman --- diff --git a/kernel/module.c b/kernel/module.c index 8c25b1a04fa..1ecf0810638 100644 --- a/kernel/module.c +++ b/kernel/module.c @@ -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