Skip to content

Commit f4dcf06

Browse files
dinghaoliurafaeljw
authored andcommitted
ACPI: video: Fix NULL pointer dereference in acpi_video_bus_add()
acpi_video_bus_add_notify_handler() could free video->input and set it to NULL on failure, but this failure would be missed in its caller acpi_video_bus_add(). As a result, when an error happens in acpi_dev_install_notify_handler(), acpi_video_bus_add() would call acpi_video_bus_remove_notify_handler(), where a potential NULL pointer video->input is dereferenced in input_unregister_device(). Fix this by adding a return value check and adjusting the following error handling code. Fixes: 6f70168 ("ACPI: video: Install Notify() handler directly") Signed-off-by: Dinghao Liu <dinghao.liu@zju.edu.cn> [ rjw: Subject and changelog edits ] Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
1 parent 6465e26 commit f4dcf06

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

drivers/acpi/acpi_video.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2057,7 +2057,9 @@ static int acpi_video_bus_add(struct acpi_device *device)
20572057
!auto_detect)
20582058
acpi_video_bus_register_backlight(video);
20592059

2060-
acpi_video_bus_add_notify_handler(video);
2060+
error = acpi_video_bus_add_notify_handler(video);
2061+
if (error)
2062+
goto err_del;
20612063

20622064
error = acpi_dev_install_notify_handler(device, ACPI_DEVICE_NOTIFY,
20632065
acpi_video_bus_notify);
@@ -2067,10 +2069,11 @@ static int acpi_video_bus_add(struct acpi_device *device)
20672069
return 0;
20682070

20692071
err_remove:
2072+
acpi_video_bus_remove_notify_handler(video);
2073+
err_del:
20702074
mutex_lock(&video_list_lock);
20712075
list_del(&video->entry);
20722076
mutex_unlock(&video_list_lock);
2073-
acpi_video_bus_remove_notify_handler(video);
20742077
acpi_video_bus_unregister_backlight(video);
20752078
err_put_video:
20762079
acpi_video_bus_put_devices(video);

0 commit comments

Comments
 (0)