lkml.org 
[lkml]   [2010]   [Sep]   [22]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 04/14] memstick: core: fix device_register() error handling
On Wed, Sep 22, 2010 at 10:53:21AM +0200, Kay Sievers wrote:
> On Wed, Sep 22, 2010 at 00:49, Greg KH <greg@kroah.com> wrote:
>
> >  int device_register(struct device *dev)
> >  {
> > +       int retval;
> > +
> >        device_initialize(dev);
> > -       return device_add(dev);
> > +       retval = device_add(dev);
> > +       if (retval)
> > +               put_device(dev);
> > +       return retval;
> >  }
>
> > Kay, what am I missing here, why can't we just do this?  Hm, the
> > side-affect might be that if device_register() fails, NO ONE had better
> > touch that device again, as it might have just been freed from the
> > system.  I wonder if that will cause problems...
>
> That looks right, besides that there might be callers already doing
> this. Which needs to be checked.

Yes, it would be. I'll go through the tree.

> I never liked this pretty useless "convenience API", which just wraps
> two simple functions and the first one can never fail anyway.

Agreed.

> We better remove that device_register() stuff entirely in the long
> run, it's not doing any good. At the kobject level we killed the same
> stuff already long ago.

It's one of the things on my "to change" list.

thanks,

greg k-h
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2010-09-22 17:53    [W:0.077 / U:0.284 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site