[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1196365883.7903.11.camel@lov.site>
Date: Thu, 29 Nov 2007 20:51:23 +0100
From: Kay Sievers <kay.sievers@...y.org>
To: Alan Stern <stern@...land.harvard.edu>
Cc: Cornelia Huck <cornelia.huck@...ibm.com>, Greg KH <greg@...ah.com>,
Kernel development list <linux-kernel@...r.kernel.org>,
Jonathan Corbet <corbet@....net>,
Randy Dunlap <randy.dunlap@...cle.com>
Subject: Re: [PATCH] kobject: make sure kobj->ktype is set before
kobject_init
On Thu, 2007-11-29 at 14:05 -0500, Alan Stern wrote:
> On Thu, 29 Nov 2007, Kay Sievers wrote:
>
> > Your error scenario confirmed my initial concern about suggesting
> > kobject_put() to clean up an initialized kobject.
> >
> > We should probably make kobject_cleanup() free only the resources taken
> > by kobject_init(), and use kobject_cleanup() instead of kobject_put()?
>
> 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.
Now we just move the exactly the same problem from _init() to
_set_name(). To free the name of an unregistered we would need to call
_put() which free()'s the whole object again. :)
> 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.
That can be done at any stage, I guess. We will rip out the name in the
struct device anyway.
Kay
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists