[PATCH] backlight: check null deference of name when device isregistered

From: Jingoo Han
Date: Fri Jan 04 2013 - 03:29:24 EST


NULL deference of name is checked when device is registered.
If the name is null, it will cause a kernel oops in dev_set_name().

Acked-by: Devendra Naga <devendra.aaru@xxxxxxxxx>
Signed-off-by: Jingoo Han <jg1.han@xxxxxxxxxxx>
---
drivers/video/backlight/backlight.c | 5 +++++
drivers/video/backlight/lcd.c | 5 +++++
2 files changed, 10 insertions(+), 0 deletions(-)

diff --git a/drivers/video/backlight/backlight.c b/drivers/video/backlight/backlight.c
index 345f666..f2db904 100644
--- a/drivers/video/backlight/backlight.c
+++ b/drivers/video/backlight/backlight.c
@@ -292,6 +292,11 @@ struct backlight_device *backlight_device_register(const char *name,
struct backlight_device *new_bd;
int rc;

+ if (name == NULL) {
+ pr_err("backlight name is null\n");
+ return ERR_PTR(-EINVAL);
+ }
+
pr_debug("backlight_device_register: name=%s\n", name);

new_bd = kzalloc(sizeof(struct backlight_device), GFP_KERNEL);
diff --git a/drivers/video/backlight/lcd.c b/drivers/video/backlight/lcd.c
index 34fb6bd..3d0ac0c 100644
--- a/drivers/video/backlight/lcd.c
+++ b/drivers/video/backlight/lcd.c
@@ -207,6 +207,11 @@ struct lcd_device *lcd_device_register(const char *name, struct device *parent,
struct lcd_device *new_ld;
int rc;

+ if (name == NULL) {
+ pr_err("lcd name is null\n");
+ return ERR_PTR(-EINVAL);
+ }
+
pr_debug("lcd_device_register: name=%s\n", name);

new_ld = kzalloc(sizeof(struct lcd_device), GFP_KERNEL);
--
1.7.2.5


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