Skip to content

Commit

Permalink
ACPI: video - fix potential crash when unloading
Browse files Browse the repository at this point in the history
thermal_cooling_device_register() returns error encoded in a pointer
when it fails in which case we need to explictly set device->cdev
to NULL so we don't try to unregister it when unloading.

Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
Acked-by: Zhang Rui <rui.zhang@intel.com>
Signed-off-by: Len Brown <len.brown@intel.com>
  • Loading branch information
Dmitry Torokhov authored and Len Brown committed Aug 30, 2009
1 parent 4e231fa commit 4b4fe3b
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion drivers/acpi/video.c
Original file line number Diff line number Diff line change
Expand Up @@ -997,8 +997,18 @@ static void acpi_video_device_find_cap(struct acpi_video_device *device)

device->cdev = thermal_cooling_device_register("LCD",
device->dev, &video_cooling_ops);
if (IS_ERR(device->cdev))
if (IS_ERR(device->cdev)) {
/*
* Set cdev to NULL so we don't crash trying to
* free it.
* Also, why the hell we are returning early and
* not attempt to register video output if cooling
* device registration failed?
* -- dtor
*/
device->cdev = NULL;
return;
}

dev_info(&device->dev->dev, "registered as cooling_device%d\n",
device->cdev->id);
Expand Down

0 comments on commit 4b4fe3b

Please sign in to comment.