lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date:	Thu, 23 Sep 2010 16:10:24 +0400
From:	Vasiliy Kulikov <segooon@...il.com>
To:	Greg KH <greg@...ah.com>
Cc:	Kay Sievers <kay.sievers@...y.org>,
	Andrew Morton <akpm@...ux-foundation.org>,
	kernel-janitors@...r.kernel.org, Tejun Heo <tj@...nel.org>,
	Jiri Slaby <jirislaby@...il.com>, linux-kernel@...r.kernel.org,
	James Bottomley <James.Bottomley@...e.de>,
	Dan Carpenter <error27@...il.com>,
	Boaz Harrosh <bharrosh@...asas.com>
Subject: Re: [PATCH 04/14] memstick: core: fix device_register() error
 handling

On Wed, Sep 22, 2010 at 08:50 -0700, Greg KH wrote:
> On Wed, Sep 22, 2010 at 10:53:21AM +0200, Kay Sievers wrote:
> > On Wed, Sep 22, 2010 at 00:49, Greg KH <greg@...ah.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.

As I see with this in-device_register patch we should check for 2 things:

1) nobody should call put_device() because of failed device_register().

2) dev has to be already got, other words its ref counter should not be zero.

Correct?

-- 
Vasiliy
--
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

Powered by Openwall GNU/*/Linux Powered by OpenVZ