From: Zhang Rui Date: Wed, 29 Jul 2009 00:53:29 +0000 (+0800) Subject: ACPI video: correct error-handling code X-Git-Tag: firefly_0821_release~9833^2~3507^2~1^2 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=e01ce79b7f6ebc5b57128ee058811aa8f9059319;p=firefly-linux-kernel-4.4.55.git ACPI video: correct error-handling code 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 Acked-by: Julia Lawall Signed-off-by: Len Brown --- diff --git a/drivers/acpi/video.c b/drivers/acpi/video.c index 05dff631591c..3f685db1a76d 100644 --- a/drivers/acpi/video.c +++ b/drivers/acpi/video.c @@ -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");