diff options
author | Young Xiao <92siuyang@gmail.com> | 2019-05-29 09:55:51 +0800 |
---|---|---|
committer | Andy Shevchenko <andriy.shevchenko@linux.intel.com> | 2019-06-12 12:42:27 +0300 |
commit | 92a74ce3c466011375bdf8282e64b13a7052aee8 (patch) | |
tree | 4b25dc231b59b718bf7f677ab688befc982fc3f5 /drivers/platform | |
parent | 8d4b2daff2567ac189a83ed99aa2f0338afbd5f0 (diff) | |
download | linux-92a74ce3c466011375bdf8282e64b13a7052aee8.tar.gz linux-92a74ce3c466011375bdf8282e64b13a7052aee8.tar.bz2 linux-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/platform')
-rw-r--r-- | drivers/platform/x86/intel_menlow.c | 8 |
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"); |