summaryrefslogtreecommitdiff
path: root/drivers/acpi/fan.c
diff options
context:
space:
mode:
authorColin Ian King <colin.king@canonical.com>2013-03-25 14:50:05 +0400
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2013-03-26 02:01:00 +0400
commitf0c29583db51104a7bc223b1e9c88d818f24ba4d (patch)
tree5bbf124ed11ab167be1f8b4137d7d3d992bcdaf7 /drivers/acpi/fan.c
parent994fa63c5b126df6e9f31ef4e09000e2e243234b (diff)
downloadlinux-f0c29583db51104a7bc223b1e9c88d818f24ba4d.tar.xz
ACPI / fan: avoid null pointer deference error
Fix a null pointer deference by acpi_driver_data() if device is null. We should only set cdev and check this is OK after we are sure device is not null. Smatch analysis: drivers/acpi/fan.c:179 acpi_fan_remove() warn: variable dereferenced before check 'device' (see line 177) Signed-off-by: Colin Ian King <colin.king@canonical.com> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Diffstat (limited to 'drivers/acpi/fan.c')
-rw-r--r--drivers/acpi/fan.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/drivers/acpi/fan.c b/drivers/acpi/fan.c
index f815da82c765..8d1c0105e113 100644
--- a/drivers/acpi/fan.c
+++ b/drivers/acpi/fan.c
@@ -174,9 +174,13 @@ static int acpi_fan_add(struct acpi_device *device)
static int acpi_fan_remove(struct acpi_device *device)
{
- struct thermal_cooling_device *cdev = acpi_driver_data(device);
+ struct thermal_cooling_device *cdev;
+
+ if (!device)
+ return -EINVAL;
- if (!device || !cdev)
+ cdev = acpi_driver_data(device);
+ if (!cdev)
return -EINVAL;
sysfs_remove_link(&device->dev.kobj, "thermal_cooling");