lkml.org 
[lkml]   [2010]   [Sep]   [21]   [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 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()!


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