Commit 63ce18cf authored by Mike Galbraith's avatar Mike Galbraith Committed by Greg Kroah-Hartman

driver core: refcounting fix

Fix a reference counting bug exposed by commit
725522b5.  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: default avatarMike Galbraith <efault@gmx.de>
Cc: Kay Sievers <kay.sievers@vrfy.org>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent 40cf67c5
...@@ -2425,6 +2425,12 @@ void module_remove_driver(struct device_driver *drv) ...@@ -2425,6 +2425,12 @@ void module_remove_driver(struct device_driver *drv)
kfree(driver_name); 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); EXPORT_SYMBOL(module_remove_driver);
#endif #endif
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment