Commit 1248a637 authored by Frank A. Uepping's avatar Frank A. Uepping Committed by Greg Kroah-Hartman

[PATCH] Driver Core: fix struct device::release issue

Signed-off-by: default avatarGreg Kroah-Hartman <greg@kroah.com>


On Saturday 27 March 2004 02:14, Greg KH wrote:
> On Sat, Mar 06, 2004 at 12:47:24PM +0100, Frank A. Uepping wrote:
> > Hi,
> > if device_add fails (e.g. bus_add_device returns an error) then the release
> > method will be called for the device. Is this a bug or a feature?
>
> Are you sure this will happen?  device_initialize() gets a reference
> that is still present after device_add() fails, right?  So release()
> will not get called.
At the label PMError, kobject_unregister is called, which decrements the
recount by 2, which will result in calling release at label Done (put_device).

kobject_unregister should be superseded by kobject_del.
Here is a patch:
parent e7414910
...@@ -245,7 +245,7 @@ int device_add(struct device *dev) ...@@ -245,7 +245,7 @@ int device_add(struct device *dev)
BusError: BusError:
device_pm_remove(dev); device_pm_remove(dev);
PMError: PMError:
kobject_unregister(&dev->kobj); kobject_del(&dev->kobj);
Error: Error:
if (parent) if (parent)
put_device(parent); put_device(parent);
......
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