lkml.org 
[lkml]   [2010]   [Nov]   [19]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] drivers: base: core: do not put noninitialized devices
On Fri, Nov 19, 2010 at 10:14:25PM +0300, Vasiliy Kulikov wrote:
> Hi Greg,
>
> On Fri, Nov 19, 2010 at 11:02 -0800, Greg KH wrote:
> > On Fri, Nov 19, 2010 at 09:41:40PM +0300, Vasiliy Kulikov wrote:
> > > If kobject_set_name_vargs() fails then put_device() frees
> > > device with zero kobj->state_initialized. This leads to WARN().
> >
> > Have you seen this happen?
>
> No, I've just analized the code. Without device_initialize() ->kobj is
> not initialized:
>
> kobject_init(&dev->kobj, &device_ktype) calls
>
> kobject_init_internal(kobj) calls
>
> kobj->state_initialized = 1;
>
> kobject_put() calls WARN if state_initialized == 0:
>
> void kobject_put(struct kobject *kobj)
> {
> if (kobj) {
> if (!kobj->state_initialized)
> WARN(1, KERN_WARNING "kobject: '%s' (%p): is not "
> "initialized, yet kobject_put() is being "
> "called.\n", kobject_name(kobj), kobj);
>
>
> I got the stack dump with similar code:
>
> struct device *dev = kzalloc(sizeof(*dev), GFP_KERNEL);
> put_device(dev);

Sure, that's illegal code, and we want to warn about that. So I would
say, if an error happens, we want to see this message so the code should
stay as-is.

thanks,

greg k-h


\
 
 \ /
  Last update: 2010-11-19 22:13    [W:0.036 / U:1.508 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site