Skip to content

Commit

Permalink
ACPI video: correct error-handling code
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Zhang Rui authored and Len Brown committed Dec 30, 2009
1 parent 6b7b284 commit e01ce79
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion drivers/acpi/video.c
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down

0 comments on commit e01ce79

Please sign in to comment.