Cc: Cornelia Huck <cornelia.huck@...>, Greg KH <greg@...>, Kernel development list <linux-kernel@...>, Jonathan Corbet <corbet@...>, Randy Dunlap <randy.dunlap@...>
I don't know... Normally *_init() routines can't fail, but this could.
Then things like device_register() would run into trouble: The caller
wouldn't know whether a failure occurred before or after the
kobject_init() call, so it wouldn't know what sort of cleanup action
was needed: kfree() or device_put().
When that sort of thing happens, the unwinding should be done by the
code responsible for whole object. For example, if device_add() fails
then the caller should go on to call device_put() rather than
kfree(dev).
That's how you would expect things to work in most cases. There aren't
many bare kobjects in the kernel.
I agree that documenting this behavior would be good.
Alan Stern
-