diff mbox

[2/4] ACPI: video - fix potential crash when unloading

Message ID 20090808075636.C8B31526EC9@mailhub.coreip.homeip.net (mailing list archive)
State Accepted
Headers show

Commit Message

Dmitry Torokhov Aug. 8, 2009, 7:26 a.m. UTC
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>
---

 drivers/acpi/video.c |   12 +++++++++++-
 1 files changed, 11 insertions(+), 1 deletions(-)


--
To unsubscribe from this list: send the line "unsubscribe linux-acpi" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Comments

Zhang, Rui Aug. 10, 2009, 2:11 a.m. UTC | #1
On Sat, 2009-08-08 at 15:26 +0800, Dmitry Torokhov wrote:
> 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>

> ---
> 
>  drivers/acpi/video.c |   12 +++++++++++-
>  1 files changed, 11 insertions(+), 1 deletions(-)
> 
> diff --git a/drivers/acpi/video.c b/drivers/acpi/video.c
> index d8e64cf..98ade4e 100644
> --- a/drivers/acpi/video.c
> +++ b/drivers/acpi/video.c
> @@ -992,8 +992,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 returnign 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);
> 

--
To unsubscribe from this list: send the line "unsubscribe linux-acpi" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Len Brown Aug. 30, 2009, 2:59 a.m. UTC | #2
applied

thanks,
Len Brown, Intel Open Source Technology Center

--
To unsubscribe from this list: send the line "unsubscribe linux-acpi" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/acpi/video.c b/drivers/acpi/video.c
index d8e64cf..98ade4e 100644
--- a/drivers/acpi/video.c
+++ b/drivers/acpi/video.c
@@ -992,8 +992,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 returnign 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);