public inbox for kernel-janitors@vger.kernel.org
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: Vasiliy Kulikov <segooon@gmail.com>
Cc: kernel-janitors@vger.kernel.org, Tejun Heo <tj@kernel.org>,
	Jiri Slaby <jirislaby@gmail.com>,
	linux-kernel@vger.kernel.org, Greg KH <greg@kroah.com>
Subject: Re: [PATCH 04/14] memstick: core: fix device_register() error
Date: Tue, 21 Sep 2010 22:20:31 +0000	[thread overview]
Message-ID: <20100921152031.30365b3f.akpm@linux-foundation.org> (raw)
In-Reply-To: <1284900889-24369-1-git-send-email-segooon@gmail.com>

On Sun, 19 Sep 2010 16:54:49 +0400
Vasiliy Kulikov <segooon@gmail.com> wrote:

> If device_register() fails then call put_device().
> See comment to device_register.
> 
> Signed-off-by: Vasiliy Kulikov <segooon@gmail.com>
> ---
>  compile tested.
> 
>  drivers/memstick/core/memstick.c |    1 +
>  1 files changed, 1 insertions(+), 0 deletions(-)
> 
> diff --git a/drivers/memstick/core/memstick.c b/drivers/memstick/core/memstick.c
> index c00fe82..4303b7e 100644
> --- a/drivers/memstick/core/memstick.c
> +++ b/drivers/memstick/core/memstick.c
> @@ -465,6 +465,7 @@ static void memstick_check(struct work_struct *work)
>  		if (!host->card) {
>  			host->card = card;
>  			if (device_register(&card->dev)) {
> +				put_device(&card->dev);
>  				kfree(host->card);
>  				host->card = NULL;
>  			}

A failed device_register() takes a bogus ref on the not-registered
device?  It's no surprise that people are getting this wrong.  

The principle of least surprise says: fix device_register()!

  reply	other threads:[~2010-09-21 22:20 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 [this message]
2010-09-21 22:49   ` [PATCH 04/14] memstick: core: fix device_register() error Greg KH
2010-09-22  8:53     ` [PATCH 04/14] memstick: core: fix device_register() error handling Kay Sievers
2010-09-22 10:02       ` Boaz Harrosh
2010-09-22 15:47         ` [PATCH 04/14] memstick: core: fix device_register() error 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
2010-09-22  9:58     ` [PATCH 04/14] memstick: core: fix device_register() error handling Boaz Harrosh
2010-09-22 15:46       ` [PATCH 04/14] memstick: core: fix device_register() error 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=20100921152031.30365b3f.akpm@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=greg@kroah.com \
    --cc=jirislaby@gmail.com \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=segooon@gmail.com \
    --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