diff mbox

int340x_thermal/processor_thermal_device: return failure when there is no ACPI device object

Message ID 1420420847.32092.1.camel@rzhang1-toshiba (mailing list archive)
State Accepted, archived
Delegated to: Zhang Rui
Headers show

Commit Message

Zhang, Rui Jan. 5, 2015, 1:20 a.m. UTC
From cd4c9293694090b02d305f2e3364618752e07693 Mon Sep 17 00:00:00 2001
From: Zhang Rui <rui.zhang@intel.com>
Date: Sun, 4 Jan 2015 16:35:59 +0800
Subject: [PATCH] int340x_thermal/processor_thermal_device: return failure when
 there is no ACPI device object

processor_thermal_device driver needs ACPI support to work. Thus, the driver
probing should fail when there is no ACPI device object asscociated.

This fixes a NULL pointer dereference when the driver is loaded
with INT340X feature disabled in BIOS.

Reported-by: Chen Yu <yu.c.chen@intel.com>
Signed-off-by: Zhang Rui <rui.zhang@intel.com>
Tested-by: Chen Yu <yu.c.chen@intel.com>
---
 drivers/thermal/int340x_thermal/processor_thermal_device.c | 2 ++
 1 file changed, 2 insertions(+)
diff mbox

Patch

diff --git a/drivers/thermal/int340x_thermal/processor_thermal_device.c b/drivers/thermal/int340x_thermal/processor_thermal_device.c
index 31bb553..0fe5dbb 100644
--- a/drivers/thermal/int340x_thermal/processor_thermal_device.c
+++ b/drivers/thermal/int340x_thermal/processor_thermal_device.c
@@ -130,6 +130,8 @@  static int proc_thermal_add(struct device *dev,
 	int ret;
 
 	adev = ACPI_COMPANION(dev);
+	if (!adev)
+		return -ENODEV;
 
 	status = acpi_evaluate_object(adev->handle, "PPCC", NULL, &buf);
 	if (ACPI_FAILURE(status))