Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e01ce79b authored by Zhang Rui's avatar Zhang Rui Committed by Len Brown
Browse files

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: default avatarZhang Rui <rui.zhang@intel.com>
Acked-by: default avatarJulia Lawall <julia@diku.dk>
Signed-off-by: default avatarLen Brown <len.brown@intel.com>
parent 6b7b2849
Loading
Loading
Loading
Loading
+3 −1
Original line number Original line Diff line number Diff line
@@ -999,8 +999,10 @@ static void acpi_video_device_find_cap(struct acpi_video_device *device)
		sprintf(name, "acpi_video%d", count++);
		sprintf(name, "acpi_video%d", count++);
		device->backlight = backlight_device_register(name,
		device->backlight = backlight_device_register(name,
			NULL, device, &acpi_backlight_ops);
			NULL, device, &acpi_backlight_ops);
		device->backlight->props.max_brightness = device->brightness->count-3;
		kfree(name);
		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,
		result = sysfs_create_link(&device->backlight->dev.kobj,
					   &device->dev->dev.kobj, "device");
					   &device->dev->dev.kobj, "device");