On Tue, Dec 3, 2024 at 4:30 AM Joe Hattori <joe@xxxxxxxxxxxxxxxxxxxxx> wrote: > > Call thermal_cooling_device_unregister() and sysfs_remove_link() in the > error path of acpi_fan_probe() to fix possible memory leak. > > Fixes: 05a83d972293 ("ACPI: register ACPI Fan as generic thermal cooling device") > Signed-off-by: Joe Hattori <joe@xxxxxxxxxxxxxxxxxxxxx> > --- > drivers/acpi/fan_core.c | 5 ++++- > 1 file changed, 4 insertions(+), 1 deletion(-) > > diff --git a/drivers/acpi/fan_core.c b/drivers/acpi/fan_core.c > index 3ea9cfcff46e..8e3f62a3745e 100644 > --- a/drivers/acpi/fan_core.c > +++ b/drivers/acpi/fan_core.c > @@ -379,11 +379,14 @@ static int acpi_fan_probe(struct platform_device *pdev) > "device"); > if (result) { > dev_err(&pdev->dev, "Failed to create sysfs link 'device'\n"); > - goto err_end; > + goto err_unregister; > } > > return 0; > > +err_unregister: > + sysfs_remove_link(&pdev->dev.kobj, "thermal_cooling"); > + thermal_cooling_device_unregister(cdev); > err_end: > if (fan->acpi4) > acpi_fan_delete_attributes(device); > -- What if the creation of the "thermal_cooling" symlink fails?