提交 2fd5a154 编写于 作者: D Dmitry Torokhov 提交者: Richard Purdie

backlight: Fix error handling

Fix error handling when registering new device
Signed-off-by: NDmitry Torokhov <dtor@mail.ru>
Signed-off-by: NRichard Purdie <rpurdie@rpsys.net>
上级 7a208463
...@@ -240,13 +240,16 @@ struct backlight_device *backlight_device_register(const char *name, ...@@ -240,13 +240,16 @@ struct backlight_device *backlight_device_register(const char *name,
rc = class_device_register(&new_bd->class_dev); rc = class_device_register(&new_bd->class_dev);
if (unlikely(rc)) { if (unlikely(rc)) {
error: kfree(new_bd); kfree(new_bd);
return ERR_PTR(rc); return ERR_PTR(rc);
} }
rc = backlight_register_fb(new_bd); rc = backlight_register_fb(new_bd);
if (unlikely(rc)) if (rc) {
goto error; class_device_unregister(&new_bd->class_dev);
return ERR_PTR(rc);
}
for (i = 0; i < ARRAY_SIZE(bl_class_device_attributes); i++) { for (i = 0; i < ARRAY_SIZE(bl_class_device_attributes); i++) {
rc = class_device_create_file(&new_bd->class_dev, rc = class_device_create_file(&new_bd->class_dev,
......
...@@ -206,14 +206,15 @@ struct lcd_device *lcd_device_register(const char *name, void *devdata, ...@@ -206,14 +206,15 @@ struct lcd_device *lcd_device_register(const char *name, void *devdata,
rc = class_device_register(&new_ld->class_dev); rc = class_device_register(&new_ld->class_dev);
if (unlikely(rc)) { if (unlikely(rc)) {
error: kfree(new_ld); kfree(new_ld);
return ERR_PTR(rc); return ERR_PTR(rc);
} }
rc = lcd_register_fb(new_ld); rc = lcd_register_fb(new_ld);
if (rc) {
if (unlikely(rc)) class_device_unregister(&new_ld->class_dev);
goto error; return ERR_PTR(rc);
}
for (i = 0; i < ARRAY_SIZE(lcd_class_device_attributes); i++) { for (i = 0; i < ARRAY_SIZE(lcd_class_device_attributes); i++) {
rc = class_device_create_file(&new_ld->class_dev, rc = class_device_create_file(&new_ld->class_dev,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册