]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
- Fix checking of wrong return value for backlight_device_register()
authorAxel Lin <axel.lin@gmail.com>
Sat, 16 Jul 2011 13:30:59 +0000 (23:30 +1000)
committerStephen Rothwell <sfr@canb.auug.org.au>
Tue, 26 Jul 2011 05:05:07 +0000 (15:05 +1000)
- Properly free allocated resources in ld9040_probe() error path and
  ld9040_remove().

Signed-off-by: Axel Lin <axel.lin@gmail.com>
Cc: Donghwa Lee <dh09.lee@samsung.com>
Cc: Richard Purdie <rpurdie@rpsys.net>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
drivers/video/backlight/ld9040.c

index 7281b2506a670ee1270aed25550bc825a756d0d7..62bcde3c97f2832a1c27a907e6ef1ec7f7cc72c4 100644 (file)
@@ -701,9 +701,9 @@ static int ld9040_probe(struct spi_device *spi)
 
        bd = backlight_device_register("ld9040-bl", &spi->dev,
                lcd, &ld9040_backlight_ops, NULL);
-       if (IS_ERR(ld)) {
-               ret = PTR_ERR(ld);
-               goto out_free_lcd;
+       if (IS_ERR(bd)) {
+               ret = PTR_ERR(bd);
+               goto out_unregister_lcd;
        }
 
        bd->props.max_brightness = MAX_BRIGHTNESS;
@@ -731,6 +731,8 @@ static int ld9040_probe(struct spi_device *spi)
        dev_info(&spi->dev, "ld9040 panel driver has been probed.\n");
        return 0;
 
+out_unregister_lcd:
+       lcd_device_unregister(lcd->ld);
 out_free_lcd:
        kfree(lcd);
        return ret;
@@ -741,6 +743,7 @@ static int __devexit ld9040_remove(struct spi_device *spi)
        struct ld9040 *lcd = dev_get_drvdata(&spi->dev);
 
        ld9040_power(lcd, FB_BLANK_POWERDOWN);
+       backlight_device_unregister(lcd->bd);
        lcd_device_unregister(lcd->ld);
        kfree(lcd);