Re: [PATCH v3 01/11] platform/x86: asus-wmi: Fix hwmon device cleanup

From: Andy Shevchenko
Date: Wed May 08 2019 - 09:27:02 EST


On Fri, Apr 19, 2019 at 1:00 PM Yurii Pavlovskyi
<yurii.pavlovskyi@xxxxxxxxx> wrote:
>
> 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.

> 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(
> + &asus->platform_device->dev, "asus", asus,
> + hwmon_attribute_groups);
> +

Temporary variable would help with readability, i.e.

struct device *dev = &asus->platform_device->dev;
...

--
With Best Regards,
Andy Shevchenko