Skip to content

Commit d91a1d1

Browse files
Wer-Wolfrafaeljw
authored andcommitted
ACPI: fan: Use platform device for devres-related actions
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>
1 parent 5876425 commit d91a1d1

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
@@ -65,9 +65,9 @@ int acpi_fan_create_attributes(struct acpi_device *device);
6565
void acpi_fan_delete_attributes(struct acpi_device *device);
6666

6767
#if IS_REACHABLE(CONFIG_HWMON)
68-
int devm_acpi_fan_create_hwmon(struct acpi_device *device);
68+
int devm_acpi_fan_create_hwmon(struct device *dev);
6969
#else
70-
static inline int devm_acpi_fan_create_hwmon(struct acpi_device *device) { return 0; };
70+
static inline int devm_acpi_fan_create_hwmon(struct device *dev) { return 0; };
7171
#endif
7272

7373
#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
@@ -166,12 +166,12 @@ static const struct hwmon_chip_info acpi_fan_hwmon_chip_info = {
166166
.info = acpi_fan_hwmon_info,
167167
};
168168

169-
int devm_acpi_fan_create_hwmon(struct acpi_device *device)
169+
int devm_acpi_fan_create_hwmon(struct device *dev)
170170
{
171-
struct acpi_fan *fan = acpi_driver_data(device);
171+
struct acpi_fan *fan = dev_get_drvdata(dev);
172172
struct device *hdev;
173173

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

0 commit comments

Comments
 (0)