ACPI video: correct error-handling code
authorZhang Rui <rui.zhang@intel.com>
Wed, 29 Jul 2009 00:53:29 +0000 (08:53 +0800)
committerLen Brown <len.brown@intel.com>
Wed, 30 Dec 2009 06:51:07 +0000 (01:51 -0500)
backlight_device_register may return an ERR_PTR
value rather than a valid pointer.

Problem found by Julia Lawall, properly fixed by Zhang Rui.

Signed-off-by: Zhang Rui <rui.zhang@intel.com>
Acked-by: Julia Lawall <julia@diku.dk>
Signed-off-by: Len Brown <len.brown@intel.com>
drivers/acpi/video.c

index 05dff631591c943918749aee95d86c474c781c62..3f685db1a76df61754524484ed530694342413da 100644 (file)
@@ -999,8 +999,10 @@ static void acpi_video_device_find_cap(struct acpi_video_device *device)
                sprintf(name, "acpi_video%d", count++);
                device->backlight = backlight_device_register(name,
                        NULL, device, &acpi_backlight_ops);
-               device->backlight->props.max_brightness = device->brightness->count-3;
                kfree(name);
+               if (IS_ERR(device->backlight))
+                       return;
+               device->backlight->props.max_brightness = device->brightness->count-3;
 
                result = sysfs_create_link(&device->backlight->dev.kobj,
                                           &device->dev->dev.kobj, "device");