aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorYoung Xiao <92siuyang@gmail.com>2019-05-29 09:55:51 +0800
committerAndy Shevchenko <andriy.shevchenko@linux.intel.com>2019-06-12 12:42:27 +0300
commit92a74ce3c466011375bdf8282e64b13a7052aee8 (patch)
tree4b25dc231b59b718bf7f677ab688befc982fc3f5 /drivers
parentplatform/x86: Remove left-over BACKLIGHT_LCD_SUPPORT (diff)
downloadlinux-dev-92a74ce3c466011375bdf8282e64b13a7052aee8.tar.xz
linux-dev-92a74ce3c466011375bdf8282e64b13a7052aee8.zip
platform/x86: intel_menlow: avoid null pointer deference error
Fix a null pointer deference by acpi_driver_data() if device is null (dereference before check). We should only set cdev and check this is OK after we are sure device is not null. Signed-off-by: Young Xiao <92siuyang@gmail.com> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/platform/x86/intel_menlow.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/drivers/platform/x86/intel_menlow.c b/drivers/platform/x86/intel_menlow.c
index 77eb8709c931..b102f6dd5693 100644
--- a/drivers/platform/x86/intel_menlow.c
+++ b/drivers/platform/x86/intel_menlow.c
@@ -180,9 +180,13 @@ static int intel_menlow_memory_add(struct acpi_device *device)
static int intel_menlow_memory_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");