public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Willy Tarreau <w@1wt.eu>
To: Kulikov Vasiliy <segooon@gmail.com>
Cc: kernel-janitors@vger.kernel.org,
	Greg Kroah-Hartman <gregkh@suse.de>,
	Peter Huewe <peterhuewe@gmx.de>,
	Andy Shevchenko <andy.shevchenko@gmail.com>,
	Julia Lawall <julia@diku.dk>,
	devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 4/9] staging: panel: fix error path
Date: Fri, 30 Jul 2010 23:11:27 +0200	[thread overview]
Message-ID: <20100730211127.GG19782@1wt.eu> (raw)
In-Reply-To: <1280488100-20819-1-git-send-email-segooon@gmail.com>

Looks fine,

Acked-by: Willy Tarreau <w@1wt.eu>

On Fri, Jul 30, 2010 at 03:08:20PM +0400, Kulikov Vasiliy wrote:
> panel_attach() poorly handles errors. On error unregister everything we
> have registered.
> 
> Signed-off-by: Kulikov Vasiliy <segooon@gmail.com>
> ---
>  drivers/staging/panel/panel.c |   22 +++++++++++++++++++---
>  1 files changed, 19 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/staging/panel/panel.c b/drivers/staging/panel/panel.c
> index 8bd7182..f58da32 100644
> --- a/drivers/staging/panel/panel.c
> +++ b/drivers/staging/panel/panel.c
> @@ -2127,12 +2127,18 @@ static void panel_attach(struct parport *port)
>  				       NULL,
>  				       /*PARPORT_DEV_EXCL */
>  				       0, (void *)&pprt);
> +	if (pprt == NULL) {
> +		pr_err("panel_attach(): port->number=%d parport=%d, "
> +		       "parport_register_device() failed\n",
> +		       port->number, parport);
> +		return;
> +	}
>  
>  	if (parport_claim(pprt)) {
>  		printk(KERN_ERR
>  		       "Panel: could not claim access to parport%d. "
>  		       "Aborting.\n", parport);
> -		return;
> +		goto err_unreg_device;
>  	}
>  
>  	/* must init LCD first, just in case an IRQ from the keypad is
> @@ -2140,13 +2146,23 @@ static void panel_attach(struct parport *port)
>  	 */
>  	if (lcd_enabled) {
>  		lcd_init();
> -		misc_register(&lcd_dev);
> +		if (misc_register(&lcd_dev))
> +			goto err_unreg_device;
>  	}
>  
>  	if (keypad_enabled) {
>  		keypad_init();
> -		misc_register(&keypad_dev);
> +		if (misc_register(&keypad_dev))
> +			goto err_lcd_unreg;
>  	}
> +	return;
> +
> +err_lcd_unreg:
> +	if (lcd_enabled)
> +		misc_deregister(&lcd_dev);
> +err_unreg_device:
> +	parport_unregister_device(pprt);
> +	pprt = NULL;
>  }
>  
>  static void panel_detach(struct parport *port)
> -- 
> 1.7.0.4

      reply	other threads:[~2010-07-30 21:14 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-07-30 11:08 [PATCH 4/9] staging: panel: fix error path Kulikov Vasiliy
2010-07-30 21:11 ` Willy Tarreau [this message]

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=20100730211127.GG19782@1wt.eu \
    --to=w@1wt.eu \
    --cc=andy.shevchenko@gmail.com \
    --cc=devel@driverdev.osuosl.org \
    --cc=gregkh@suse.de \
    --cc=julia@diku.dk \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=peterhuewe@gmx.de \
    --cc=segooon@gmail.com \
    /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