Skip to content

Commit c386ed8

Browse files
committed
ACPI: fan: Use platform device for devres-related actions
JIRA: https://issues.redhat.com/browse/RHEL-114091 commit d91a1d1 Author: Armin Wolf <W_Armin@gmx.de> Date: Wed Oct 8 01:41:46 2025 +0200 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: 35c50d8 ("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: Mark Langsdorf <mlangsdo@redhat.com>
1 parent 26b7009 commit c386ed8

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

drivers/acpi/fan.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,9 @@ int acpi_fan_create_attributes(struct acpi_device *device);
6464
void acpi_fan_delete_attributes(struct acpi_device *device);
6565

6666
#if IS_REACHABLE(CONFIG_HWMON)
67-
int devm_acpi_fan_create_hwmon(struct acpi_device *device);
67+
int devm_acpi_fan_create_hwmon(struct device *dev);
6868
#else
69-
static inline int devm_acpi_fan_create_hwmon(struct acpi_device *device) { return 0; };
69+
static inline int devm_acpi_fan_create_hwmon(struct device *dev) { return 0; };
7070
#endif
7171

7272
#endif

drivers/acpi/fan_core.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,7 @@ static int acpi_fan_probe(struct platform_device *pdev)
347347
}
348348

349349
if (fan->has_fst) {
350-
result = devm_acpi_fan_create_hwmon(device);
350+
result = devm_acpi_fan_create_hwmon(&pdev->dev);
351351
if (result)
352352
return result;
353353

drivers/acpi/fan_hwmon.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -167,12 +167,12 @@ static const struct hwmon_chip_info acpi_fan_hwmon_chip_info = {
167167
.info = acpi_fan_hwmon_info,
168168
};
169169

170-
int devm_acpi_fan_create_hwmon(struct acpi_device *device)
170+
int devm_acpi_fan_create_hwmon(struct device *dev)
171171
{
172-
struct acpi_fan *fan = acpi_driver_data(device);
172+
struct acpi_fan *fan = dev_get_drvdata(dev);
173173
struct device *hdev;
174174

175-
hdev = devm_hwmon_device_register_with_info(&device->dev, "acpi_fan", fan,
176-
&acpi_fan_hwmon_chip_info, NULL);
175+
hdev = devm_hwmon_device_register_with_info(dev, "acpi_fan", fan, &acpi_fan_hwmon_chip_info,
176+
NULL);
177177
return PTR_ERR_OR_ZERO(hdev);
178178
}

0 commit comments

Comments
 (0)