From: Vasiliy Kulikov <segooon@gmail.com>
To: Greg KH <greg@kroah.com>
Cc: Kay Sievers <kay.sievers@vrfy.org>,
Andrew Morton <akpm@linux-foundation.org>,
kernel-janitors@vger.kernel.org, Tejun Heo <tj@kernel.org>,
Jiri Slaby <jirislaby@gmail.com>,
linux-kernel@vger.kernel.org,
James Bottomley <James.Bottomley@suse.de>,
Dan Carpenter <error27@gmail.com>,
Boaz Harrosh <bharrosh@panasas.com>
Subject: Re: [PATCH 04/14] memstick: core: fix device_register() error handling
Date: Thu, 23 Sep 2010 16:10:24 +0400 [thread overview]
Message-ID: <20100923121024.GA26888@albatros> (raw)
In-Reply-To: <20100922155004.GC26178@kroah.com>
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@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.
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
next prev parent reply other threads:[~2010-09-23 12:10 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-09-19 12:54 [PATCH 04/14] memstick: core: fix device_register() error handling Vasiliy Kulikov
2010-09-21 22:20 ` Andrew Morton
2010-09-21 22:49 ` Greg KH
2010-09-22 8:53 ` Kay Sievers
2010-09-22 10:02 ` Boaz Harrosh
2010-09-22 15:47 ` Greg KH
2010-09-22 15:56 ` James Bottomley
2010-09-22 16:20 ` Greg KH
2010-09-22 16:23 ` James Bottomley
2010-09-22 15:50 ` Greg KH
2010-09-23 12:10 ` Vasiliy Kulikov [this message]
2010-09-22 9:58 ` Boaz Harrosh
2010-09-22 15:46 ` Greg KH
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20100923121024.GA26888@albatros \
--to=segooon@gmail.com \
--cc=James.Bottomley@suse.de \
--cc=akpm@linux-foundation.org \
--cc=bharrosh@panasas.com \
--cc=error27@gmail.com \
--cc=greg@kroah.com \
--cc=jirislaby@gmail.com \
--cc=kay.sievers@vrfy.org \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=tj@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox