driver core: refcounting fix

Fix a reference counting bug exposed by commit
725522b545.  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>
This commit is contained in:
Mike Galbraith 2007-02-21 12:45:35 -08:00 committed by Greg Kroah-Hartman
parent 40cf67c5fc
commit 63ce18cfe6

View 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