Cc: Cornelia Huck <cornelia.huck@...>, Greg KH <greg@...>, Kernel development list <linux-kernel@...>, Jonathan Corbet <corbet@...>, Randy Dunlap <randy.dunlap@...>
My conclusion is different. We should make kobject_init() not consume
any resources at all; just initialize various fields. That way it
would be okay to call either kfree() or kobject_put() on an initialized
kobject. And then when something like device_register() fails, the
caller would know the proper thing to do would be to call the put()
routine, always.
Of course, once the name has been assigned, only kobject_put() should
be used.
There's another good reason for not assigning the name in
kobject_init(): Code that uses kobjects (like the driver core) doesn't
set the name until later.
Alan Stern
-