backlight: Fix error handling
authorDmitry Torokhov <dtor@mail.ru>
Wed, 7 Feb 2007 22:25:50 +0000 (22:25 +0000)
committerRichard Purdie <rpurdie@rpsys.net>
Tue, 20 Feb 2007 08:35:09 +0000 (08:35 +0000)
Fix error handling when registering new device

Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
Signed-off-by: Richard Purdie <rpurdie@rpsys.net>
drivers/video/backlight/backlight.c
drivers/video/backlight/lcd.c

index 9601bfe309ac2744c922a1f612eb4b6188e12aa0..71056f8b621ac6de0b1b839090b9def38ff4575a 100644 (file)
@@ -240,13 +240,16 @@ struct backlight_device *backlight_device_register(const char *name,
 
        rc = class_device_register(&new_bd->class_dev);
        if (unlikely(rc)) {
-error:         kfree(new_bd);
+               kfree(new_bd);
                return ERR_PTR(rc);
        }
 
        rc = backlight_register_fb(new_bd);
-       if (unlikely(rc))
-               goto error;
+       if (rc) {
+               class_device_unregister(&new_bd->class_dev);
+               return ERR_PTR(rc);
+       }
+
 
        for (i = 0; i < ARRAY_SIZE(bl_class_device_attributes); i++) {
                rc = class_device_create_file(&new_bd->class_dev,
index f6e041627edbb874419cc146ecd6df167fbe67c1..f95f0e33101d9211e14a8cb5dedb927a95152a27 100644 (file)
@@ -206,14 +206,15 @@ struct lcd_device *lcd_device_register(const char *name, void *devdata,
 
        rc = class_device_register(&new_ld->class_dev);
        if (unlikely(rc)) {
-error:         kfree(new_ld);
+               kfree(new_ld);
                return ERR_PTR(rc);
        }
 
        rc = lcd_register_fb(new_ld);
-
-       if (unlikely(rc))
-               goto error;
+       if (rc) {
+               class_device_unregister(&new_ld->class_dev);
+               return ERR_PTR(rc);
+       }
 
        for (i = 0; i < ARRAY_SIZE(lcd_class_device_attributes); i++) {
                rc = class_device_create_file(&new_ld->class_dev,