Re: [PATCH] kobject: make sure kobj->ktype is set before kobject_init

2007-11-30 Thread Cornelia Huck
On Thu, 29 Nov 2007 21:26:40 +0100, Kay Sievers <[EMAIL PROTECTED]> wrote: > On Thu, 2007-11-29 at 21:20 +0100, Kay Sievers wrote: > > On Thu, 2007-11-29 at 15:09 -0500, Alan Stern wrote: > > > On Thu, 29 Nov 2007, Kay Sievers wrote: > > > > > > There's another good reason for not assigning the

Re: [PATCH] kobject: make sure kobj-ktype is set before kobject_init

2007-11-30 Thread Cornelia Huck
On Thu, 29 Nov 2007 21:26:40 +0100, Kay Sievers [EMAIL PROTECTED] wrote: On Thu, 2007-11-29 at 21:20 +0100, Kay Sievers wrote: On Thu, 2007-11-29 at 15:09 -0500, Alan Stern wrote: On Thu, 29 Nov 2007, Kay Sievers wrote: There's another good reason for not assigning the name in

Re: [PATCH] kobject: make sure kobj->ktype is set before kobject_init

2007-11-29 Thread Kay Sievers
On Thu, 2007-11-29 at 21:20 +0100, Kay Sievers wrote: > On Thu, 2007-11-29 at 15:09 -0500, Alan Stern wrote: > > On Thu, 29 Nov 2007, Kay Sievers wrote: > > > > There's another good reason for not assigning the name in > > > > kobject_init(): Code that uses kobjects (like the driver core) doesn't

Re: [PATCH] kobject: make sure kobj->ktype is set before kobject_init

2007-11-29 Thread Kay Sievers
On Thu, 2007-11-29 at 15:09 -0500, Alan Stern wrote: > On Thu, 29 Nov 2007, Kay Sievers wrote: > > > > 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

Re: [PATCH] kobject: make sure kobj->ktype is set before kobject_init

2007-11-29 Thread Alan Stern
On Thu, 29 Nov 2007, Kay Sievers wrote: > > 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

Re: [PATCH] kobject: make sure kobj->ktype is set before kobject_init

2007-11-29 Thread Kay Sievers
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

Re: [PATCH] kobject: make sure kobj->ktype is set before kobject_init

2007-11-29 Thread Alan Stern
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

Re: [PATCH] kobject: make sure kobj->ktype is set before kobject_init

2007-11-29 Thread Kay Sievers
On Thu, 2007-11-29 at 13:04 -0500, Alan Stern wrote: > On Thu, 29 Nov 2007, Kay Sievers wrote: > > > > > Sounds fine, maybe we should also pass the name along, so it will be > > > > obvious what happens here: > > > > int kobject_init(struct kobject *kobj, struct kobj_type *type, const > > > >

Re: [PATCH] kobject: make sure kobj->ktype is set before kobject_init

2007-11-29 Thread Alan Stern
On Thu, 29 Nov 2007, Kay Sievers wrote: > > > Sounds fine, maybe we should also pass the name along, so it will be > > > obvious what happens here: > > > int kobject_init(struct kobject *kobj, struct kobj_type *type, const > > > char *fmt, ...) > > > > I don't know... Normally *_init()

Re: [PATCH] kobject: make sure kobj->ktype is set before kobject_init

2007-11-29 Thread Kay Sievers
On Thu, 2007-11-29 at 12:06 -0500, Alan Stern wrote: > On Thu, 29 Nov 2007, Kay Sievers wrote: > > > > In fact, if we were designing the kobject API from scratch, I'd suggest > > > making the ktype value an argument to kobject_init() so that it > > > _couldn't_ be omitted. > > > > Sounds fine,

Re: [PATCH] kobject: make sure kobj->ktype is set before kobject_init

2007-11-29 Thread Alan Stern
On Thu, 29 Nov 2007, Kay Sievers wrote: > > In fact, if we were designing the kobject API from scratch, I'd suggest > > making the ktype value an argument to kobject_init() so that it > > _couldn't_ be omitted. > > Sounds fine, maybe we should also pass the name along, so it will be > obvious

Re: [PATCH] kobject: make sure kobj->ktype is set before kobject_init

2007-11-29 Thread Cornelia Huck
On Thu, 29 Nov 2007 17:04:40 +0100, Kay Sievers <[EMAIL PROTECTED]> wrote: > On Thu, 2007-11-29 at 10:54 -0500, Alan Stern wrote: > > On Thu, 29 Nov 2007, Kay Sievers wrote: > > > > > > And if someone calls kobject_put() after kobject_init() to clean up, > > > > their release function will not

Re: [PATCH] kobject: make sure kobj->ktype is set before kobject_init

2007-11-29 Thread Kay Sievers
On Thu, 2007-11-29 at 10:54 -0500, Alan Stern wrote: > On Thu, 29 Nov 2007, Kay Sievers wrote: > > > > And if someone calls kobject_put() after kobject_init() to clean up, > > > their release function will not be called if they didn't set the ktype. > > > So the check really belongs into

Re: [PATCH] kobject: make sure kobj->ktype is set before kobject_init

2007-11-29 Thread Alan Stern
On Thu, 29 Nov 2007, Kay Sievers wrote: > > And if someone calls kobject_put() after kobject_init() to clean up, > > their release function will not be called if they didn't set the ktype. > > So the check really belongs into kobject_init() IMO. Right. And even though cleaning up no longer

Re: [PATCH] kobject: make sure kobj->ktype is set before kobject_init

2007-11-29 Thread Cornelia Huck
On Thu, 29 Nov 2007 11:59:06 +0100, Kay Sievers <[EMAIL PROTECTED]> wrote: > On Thu, 2007-11-29 at 11:05 +0100, Cornelia Huck wrote: > > On Wed, 28 Nov 2007 17:00:57 -0500 (EST), > > Alan Stern <[EMAIL PROTECTED]> wrote: > > > On Wed, 28 Nov 2007, Greg KH wrote: > > > > On Wed, Nov 28, 2007 at

Re: [PATCH] kobject: make sure kobj->ktype is set before kobject_init

2007-11-29 Thread Kay Sievers
On Thu, 2007-11-29 at 11:05 +0100, Cornelia Huck wrote: > On Wed, 28 Nov 2007 17:00:57 -0500 (EST), > Alan Stern <[EMAIL PROTECTED]> wrote: > > On Wed, 28 Nov 2007, Greg KH wrote: > > > On Wed, Nov 28, 2007 at 03:42:00PM -0500, Alan Stern wrote: > > > > This patch (as1020) adds a check to

Re: [PATCH] kobject: make sure kobj->ktype is set before kobject_init

2007-11-29 Thread Cornelia Huck
On Wed, 28 Nov 2007 17:00:57 -0500 (EST), Alan Stern <[EMAIL PROTECTED]> wrote: > On Wed, 28 Nov 2007, Greg KH wrote: > > > On Wed, Nov 28, 2007 at 03:42:00PM -0500, Alan Stern wrote: > > > This patch (as1020) adds a check to kobject_init() to insure that the > > > ktype field is not NULL. This

Re: [PATCH] kobject: make sure kobj-ktype is set before kobject_init

2007-11-29 Thread Cornelia Huck
On Wed, 28 Nov 2007 17:00:57 -0500 (EST), Alan Stern [EMAIL PROTECTED] wrote: On Wed, 28 Nov 2007, Greg KH wrote: On Wed, Nov 28, 2007 at 03:42:00PM -0500, Alan Stern wrote: This patch (as1020) adds a check to kobject_init() to insure that the ktype field is not NULL. This is just for

Re: [PATCH] kobject: make sure kobj-ktype is set before kobject_init

2007-11-29 Thread Kay Sievers
On Thu, 2007-11-29 at 11:05 +0100, Cornelia Huck wrote: On Wed, 28 Nov 2007 17:00:57 -0500 (EST), Alan Stern [EMAIL PROTECTED] wrote: On Wed, 28 Nov 2007, Greg KH wrote: On Wed, Nov 28, 2007 at 03:42:00PM -0500, Alan Stern wrote: This patch (as1020) adds a check to kobject_init() to

Re: [PATCH] kobject: make sure kobj-ktype is set before kobject_init

2007-11-29 Thread Cornelia Huck
On Thu, 29 Nov 2007 11:59:06 +0100, Kay Sievers [EMAIL PROTECTED] wrote: On Thu, 2007-11-29 at 11:05 +0100, Cornelia Huck wrote: On Wed, 28 Nov 2007 17:00:57 -0500 (EST), Alan Stern [EMAIL PROTECTED] wrote: On Wed, 28 Nov 2007, Greg KH wrote: On Wed, Nov 28, 2007 at 03:42:00PM -0500,

Re: [PATCH] kobject: make sure kobj-ktype is set before kobject_init

2007-11-29 Thread Alan Stern
On Thu, 29 Nov 2007, Kay Sievers wrote: And if someone calls kobject_put() after kobject_init() to clean up, their release function will not be called if they didn't set the ktype. So the check really belongs into kobject_init() IMO. Right. And even though cleaning up no longer needs to

Re: [PATCH] kobject: make sure kobj-ktype is set before kobject_init

2007-11-29 Thread Kay Sievers
On Thu, 2007-11-29 at 10:54 -0500, Alan Stern wrote: On Thu, 29 Nov 2007, Kay Sievers wrote: And if someone calls kobject_put() after kobject_init() to clean up, their release function will not be called if they didn't set the ktype. So the check really belongs into kobject_init() IMO.

Re: [PATCH] kobject: make sure kobj-ktype is set before kobject_init

2007-11-29 Thread Cornelia Huck
On Thu, 29 Nov 2007 17:04:40 +0100, Kay Sievers [EMAIL PROTECTED] wrote: On Thu, 2007-11-29 at 10:54 -0500, Alan Stern wrote: On Thu, 29 Nov 2007, Kay Sievers wrote: And if someone calls kobject_put() after kobject_init() to clean up, their release function will not be called if

Re: [PATCH] kobject: make sure kobj-ktype is set before kobject_init

2007-11-29 Thread Alan Stern
On Thu, 29 Nov 2007, Kay Sievers wrote: In fact, if we were designing the kobject API from scratch, I'd suggest making the ktype value an argument to kobject_init() so that it _couldn't_ be omitted. Sounds fine, maybe we should also pass the name along, so it will be obvious what

Re: [PATCH] kobject: make sure kobj-ktype is set before kobject_init

2007-11-29 Thread Kay Sievers
On Thu, 2007-11-29 at 12:06 -0500, Alan Stern wrote: On Thu, 29 Nov 2007, Kay Sievers wrote: In fact, if we were designing the kobject API from scratch, I'd suggest making the ktype value an argument to kobject_init() so that it _couldn't_ be omitted. Sounds fine, maybe we

Re: [PATCH] kobject: make sure kobj-ktype is set before kobject_init

2007-11-29 Thread Alan Stern
On Thu, 29 Nov 2007, Kay Sievers wrote: Sounds fine, maybe we should also pass the name along, so it will be obvious what happens here: int kobject_init(struct kobject *kobj, struct kobj_type *type, const char *fmt, ...) I don't know... Normally *_init() routines can't fail,

Re: [PATCH] kobject: make sure kobj-ktype is set before kobject_init

2007-11-29 Thread Kay Sievers
On Thu, 2007-11-29 at 13:04 -0500, Alan Stern wrote: On Thu, 29 Nov 2007, Kay Sievers wrote: Sounds fine, maybe we should also pass the name along, so it will be obvious what happens here: int kobject_init(struct kobject *kobj, struct kobj_type *type, const char *fmt, ...)

Re: [PATCH] kobject: make sure kobj-ktype is set before kobject_init

2007-11-29 Thread Alan Stern
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

Re: [PATCH] kobject: make sure kobj-ktype is set before kobject_init

2007-11-29 Thread Kay Sievers
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

Re: [PATCH] kobject: make sure kobj-ktype is set before kobject_init

2007-11-29 Thread Alan Stern
On Thu, 29 Nov 2007, Kay Sievers wrote: 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

Re: [PATCH] kobject: make sure kobj-ktype is set before kobject_init

2007-11-29 Thread Kay Sievers
On Thu, 2007-11-29 at 15:09 -0500, Alan Stern wrote: On Thu, 29 Nov 2007, Kay Sievers wrote: 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()

Re: [PATCH] kobject: make sure kobj-ktype is set before kobject_init

2007-11-29 Thread Kay Sievers
On Thu, 2007-11-29 at 21:20 +0100, Kay Sievers wrote: On Thu, 2007-11-29 at 15:09 -0500, Alan Stern wrote: On Thu, 29 Nov 2007, Kay Sievers wrote: There's another good reason for not assigning the name in kobject_init(): Code that uses kobjects (like the driver core) doesn't set

Re: [PATCH] kobject: make sure kobj->ktype is set before kobject_init

2007-11-28 Thread Greg KH
On Wed, Nov 28, 2007 at 05:00:57PM -0500, Alan Stern wrote: > On Wed, 28 Nov 2007, Greg KH wrote: > > > On Wed, Nov 28, 2007 at 03:42:00PM -0500, Alan Stern wrote: > > > This patch (as1020) adds a check to kobject_init() to insure that the > > > ktype field is not NULL. This is just for safety's

Re: [PATCH] kobject: make sure kobj->ktype is set before kobject_init

2007-11-28 Thread Alan Stern
On Wed, 28 Nov 2007, Greg KH wrote: > On Wed, Nov 28, 2007 at 03:42:00PM -0500, Alan Stern wrote: > > This patch (as1020) adds a check to kobject_init() to insure that the > > ktype field is not NULL. This is just for safety's sake; as far as I > > know there are no remaining places where the

Re: [PATCH] kobject: make sure kobj->ktype is set before kobject_init

2007-11-28 Thread Greg KH
On Wed, Nov 28, 2007 at 03:42:00PM -0500, Alan Stern wrote: > This patch (as1020) adds a check to kobject_init() to insure that the > ktype field is not NULL. This is just for safety's sake; as far as I > know there are no remaining places where the field is left unset. But > ironically,

Re: [PATCH] kobject: make sure kobj->ktype is set before kobject_init

2007-11-28 Thread Kay Sievers
On Wed, 2007-11-28 at 15:42 -0500, Alan Stern wrote: > This patch (as1020) adds a check to kobject_init() to insure that the > ktype field is not NULL. That's good. > This is just for safety's sake; as far as I > know there are no remaining places where the field is left unset. But >

[PATCH] kobject: make sure kobj->ktype is set before kobject_init

2007-11-28 Thread Alan Stern
This patch (as1020) adds a check to kobject_init() to insure that the ktype field is not NULL. This is just for safety's sake; as far as I know there are no remaining places where the field is left unset. But ironically, kset_init() did fail to set it! The patch fixes that and removes some

Re: [PATCH] kobject: make sure kobj-ktype is set before kobject_init

2007-11-28 Thread Kay Sievers
On Wed, 2007-11-28 at 15:42 -0500, Alan Stern wrote: This patch (as1020) adds a check to kobject_init() to insure that the ktype field is not NULL. That's good. This is just for safety's sake; as far as I know there are no remaining places where the field is left unset. But ironically,

[PATCH] kobject: make sure kobj-ktype is set before kobject_init

2007-11-28 Thread Alan Stern
This patch (as1020) adds a check to kobject_init() to insure that the ktype field is not NULL. This is just for safety's sake; as far as I know there are no remaining places where the field is left unset. But ironically, kset_init() did fail to set it! The patch fixes that and removes some

Re: [PATCH] kobject: make sure kobj-ktype is set before kobject_init

2007-11-28 Thread Alan Stern
On Wed, 28 Nov 2007, Greg KH wrote: On Wed, Nov 28, 2007 at 03:42:00PM -0500, Alan Stern wrote: This patch (as1020) adds a check to kobject_init() to insure that the ktype field is not NULL. This is just for safety's sake; as far as I know there are no remaining places where the field is

Re: [PATCH] kobject: make sure kobj-ktype is set before kobject_init

2007-11-28 Thread Greg KH
On Wed, Nov 28, 2007 at 03:42:00PM -0500, Alan Stern wrote: This patch (as1020) adds a check to kobject_init() to insure that the ktype field is not NULL. This is just for safety's sake; as far as I know there are no remaining places where the field is left unset. But ironically, kset_init()

Re: [PATCH] kobject: make sure kobj-ktype is set before kobject_init

2007-11-28 Thread Greg KH
On Wed, Nov 28, 2007 at 05:00:57PM -0500, Alan Stern wrote: On Wed, 28 Nov 2007, Greg KH wrote: On Wed, Nov 28, 2007 at 03:42:00PM -0500, Alan Stern wrote: This patch (as1020) adds a check to kobject_init() to insure that the ktype field is not NULL. This is just for safety's sake; as