From: Dave Hansen on
On Mon, 2010-05-17 at 13:42 +0800, Axel Lin wrote:
> In current implementation, if device_create_file failed in
> register_nasgpio_led,
> led_classdev_unregister will be executed twice.
> ( in register_nasgpio_led it calls led_classdev_unregister before
> return and in nas_gpio_init out_err )
>
> This patch fixes it by only unregistering those that were successfully
> registered in out_err.
> ( not including last failed register_nasgpio_led call )

Did you actually run into this, or did you find this just auditing code?

> diff --git a/drivers/leds/leds-ss4200.c b/drivers/leds/leds-ss4200.c
> index 51477ec..a688293 100644
> --- a/drivers/leds/leds-ss4200.c
> +++ b/drivers/leds/leds-ss4200.c
> @@ -534,7 +534,7 @@ static int __init nas_gpio_init(void)
> set_power_light_amber_noblink();
> return 0;
> out_err:
> - for (; i >= 0; i--)
> + for (i--; i >= 0; i--)
> unregister_nasgpio_led(i);
> pci_unregister_driver(&nas_gpio_pci_driver);
> return ret;

That i-- took me a minute to grok, but there isn't something immensely
better here. If you have to resubmit these somehow, please add a
comment there. But, otherwise,

Acked-by: Dave Hansen <dave(a)sr71.net>

-- Dave

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo(a)vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/