[patch 2/6] Fix error handling when registering new device

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Backlight: fix error handling when registering new device

Signed-off-by: Dmitry Torokhov <[email protected]>
---

 drivers/video/backlight/backlight.c |    8 +++++---
 drivers/video/backlight/lcd.c       |    8 +++++---
 2 files changed, 10 insertions(+), 6 deletions(-)

Index: work/drivers/video/backlight/backlight.c
===================================================================
--- work.orig/drivers/video/backlight/backlight.c
+++ work/drivers/video/backlight/backlight.c
@@ -205,7 +205,7 @@ struct backlight_device *backlight_devic
 
 	rc = class_device_register(&new_bd->class_dev);
 	if (unlikely(rc)) {
-error:		kfree(new_bd);
+		kfree(new_bd);
 		return ERR_PTR(rc);
 	}
 
@@ -213,8 +213,10 @@ error:		kfree(new_bd);
 	new_bd->fb_notif.notifier_call = fb_notifier_callback;
 
 	rc = fb_register_client(&new_bd->fb_notif);
-	if (unlikely(rc))
-		goto error;
+	if (unlikely(rc)) {
+		class_device_unregister(&new_bd->class_dev);
+		return ERR_PTR(rc);
+	}
 
 	return new_bd;
 }
Index: work/drivers/video/backlight/lcd.c
===================================================================
--- work.orig/drivers/video/backlight/lcd.c
+++ work/drivers/video/backlight/lcd.c
@@ -177,7 +177,7 @@ struct lcd_device *lcd_device_register(c
 
 	rc = class_device_register(&new_ld->class_dev);
 	if (unlikely(rc)) {
-error:		kfree(new_ld);
+		kfree(new_ld);
 		return ERR_PTR(rc);
 	}
 
@@ -185,8 +185,10 @@ error:		kfree(new_ld);
 	new_ld->fb_notif.notifier_call = fb_notifier_callback;
 
 	rc = fb_register_client(&new_ld->fb_notif);
-	if (unlikely(rc))
-		goto error;
+	if (unlikely(rc)) {
+		class_device_unregister(&new_ld->class_dev);
+		return ERR_PTR(rc);
+	}
 
 	return new_ld;
 }
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux