summaryrefslogtreecommitdiffstats
path: root/drivers/platform
diff options
context:
space:
mode:
authorYurii Pavlovskyi <yurii.pavlovskyi@gmail.com>2019-05-14 20:50:30 +0200
committerAndy Shevchenko <andriy.shevchenko@linux.intel.com>2019-06-17 14:22:47 +0200
commitcd10ee006ab504b2b9c5ed992cc06d3e110c6311 (patch)
treeffb775ec9399b1a2db36c880b974a3c0d2b4f3f1 /drivers/platform
parentplatform/x86: intel_telemetry: no need to check return value of debugfs_creat... (diff)
downloadlinux-cd10ee006ab504b2b9c5ed992cc06d3e110c6311.tar.xz
linux-cd10ee006ab504b2b9c5ed992cc06d3e110c6311.zip
platform/x86: asus-wmi: Fix hwmon device cleanup
The driver does not clean up the hwmon device on exit or error. To reproduce the bug, repeat rmmod, insmod to verify that device number /sys/devices/platform/asus-nb-wmi/hwmon/hwmon?? grows every time. Replace call for registering device with devm_* version that unregisters it automatically. Signed-off-by: Yurii Pavlovskyi <yurii.pavlovskyi@gmail.com> Reviewed-by: Daniel Drake <drake@endlessm.com> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Diffstat (limited to 'drivers/platform')
-rw-r--r--drivers/platform/x86/asus-wmi.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wmi.c
index 7e946ce7f66f..6a590ec4c4ef 100644
--- a/drivers/platform/x86/asus-wmi.c
+++ b/drivers/platform/x86/asus-wmi.c
@@ -1428,11 +1428,12 @@ __ATTRIBUTE_GROUPS(hwmon_attribute);
static int asus_wmi_hwmon_init(struct asus_wmi *asus)
{
+ struct device *dev = &asus->platform_device->dev;
struct device *hwmon;
- hwmon = hwmon_device_register_with_groups(&asus->platform_device->dev,
- "asus", asus,
- hwmon_attribute_groups);
+ hwmon = devm_hwmon_device_register_with_groups(dev, "asus", asus,
+ hwmon_attribute_groups);
+
if (IS_ERR(hwmon)) {
pr_err("Could not register asus hwmon device\n");
return PTR_ERR(hwmon);