summaryrefslogtreecommitdiffstats
path: root/drivers/acpi/video.c
diff options
context:
space:
mode:
authorDmitry Torokhov <dmitry.torokhov@gmail.com>2009-08-08 09:26:25 +0200
committerLen Brown <len.brown@intel.com>2009-08-30 04:58:19 +0200
commit4b4fe3b62e8d88068083218d3e42c45223b51d29 (patch)
tree6d08c8117fc004da8bae7312a3715f1c11ef3ced /drivers/acpi/video.c
parentACPI video: ignore buggy _BQC (diff)
downloadlinux-4b4fe3b62e8d88068083218d3e42c45223b51d29.tar.xz
linux-4b4fe3b62e8d88068083218d3e42c45223b51d29.zip
ACPI: video - fix potential crash when unloading
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>
Diffstat (limited to 'drivers/acpi/video.c')
-rw-r--r--drivers/acpi/video.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/drivers/acpi/video.c b/drivers/acpi/video.c
index 2020907921cc..aab385188599 100644
--- a/drivers/acpi/video.c
+++ b/drivers/acpi/video.c
@@ -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);