提交 4b4fe3b6 编写于 作者: D Dmitry Torokhov 提交者: Len Brown

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: NDmitry Torokhov <dtor@mail.ru>
Acked-by: NZhang Rui <rui.zhang@intel.com>
Signed-off-by: NLen Brown <len.brown@intel.com>
上级 4e231fa4
......@@ -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);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册