]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
ACPI: fan: Use platform device for devres-related actions
authorArmin Wolf <W_Armin@gmx.de>
Sun, 2 Nov 2025 14:35:14 +0000 (09:35 -0500)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 13 Nov 2025 20:34:01 +0000 (15:34 -0500)
[ Upstream commit d91a1d129b63614fa4c2e45e60918409ce36db7e ]

Device-managed resources are cleaned up when the driver unbinds from
the underlying device. In our case this is the platform device as this
driver is a platform driver. Registering device-managed resources on
the associated ACPI device will thus result in a resource leak when
this driver unbinds.

Ensure that any device-managed resources are only registered on the
platform device to ensure that they are cleaned up during removal.

Fixes: 35c50d853adc ("ACPI: fan: Add hwmon support")
Signed-off-by: Armin Wolf <W_Armin@gmx.de>
Cc: 6.11+ <stable@vger.kernel.org> # 6.11+
Link: https://patch.msgid.link/20251007234149.2769-4-W_Armin@gmx.de
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/acpi/fan.h
drivers/acpi/fan_core.c
drivers/acpi/fan_hwmon.c

index c1c527f620acc983403be199ea5a6cb7511dd6f8..612ccc4c282796af9e3c70d7c84d825e8e5eaa3d 100644 (file)
@@ -63,9 +63,9 @@ int acpi_fan_create_attributes(struct acpi_device *device);
 void acpi_fan_delete_attributes(struct acpi_device *device);
 
 #if IS_REACHABLE(CONFIG_HWMON)
-int devm_acpi_fan_create_hwmon(struct acpi_device *device);
+int devm_acpi_fan_create_hwmon(struct device *dev);
 #else
-static inline int devm_acpi_fan_create_hwmon(struct acpi_device *device) { return 0; };
+static inline int devm_acpi_fan_create_hwmon(struct device *dev) { return 0; };
 #endif
 
 #endif
index 5a8a254e9a78787da072df37e9809ec6f2d68c60..3d85bec8c3d1fbba1a7d44c027873273e8ebb54a 100644 (file)
@@ -357,7 +357,7 @@ static int acpi_fan_probe(struct platform_device *pdev)
        }
 
        if (fan->has_fst) {
-               result = devm_acpi_fan_create_hwmon(device);
+               result = devm_acpi_fan_create_hwmon(&pdev->dev);
                if (result)
                        return result;
 
index 4209a9923efcb948ac9d5b5c87b20b50b824b429..4b2c2007f2d7fa5f0c58c76d73b4957cf7306400 100644 (file)
@@ -166,12 +166,12 @@ static const struct hwmon_chip_info acpi_fan_hwmon_chip_info = {
        .info = acpi_fan_hwmon_info,
 };
 
-int devm_acpi_fan_create_hwmon(struct acpi_device *device)
+int devm_acpi_fan_create_hwmon(struct device *dev)
 {
-       struct acpi_fan *fan = acpi_driver_data(device);
+       struct acpi_fan *fan = dev_get_drvdata(dev);
        struct device *hdev;
 
-       hdev = devm_hwmon_device_register_with_info(&device->dev, "acpi_fan", fan,
-                                                   &acpi_fan_hwmon_chip_info, NULL);
+       hdev = devm_hwmon_device_register_with_info(dev, "acpi_fan", fan, &acpi_fan_hwmon_chip_info,
+                                                   NULL);
        return PTR_ERR_OR_ZERO(hdev);
 }