Re: [PATCH] ACPI: fan: cleanup resources in the error path of .probe()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Rafael,

Thank you for your review.

On 12/11/24 03:42, Rafael J. Wysocki wrote:
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?

Should have handled that case as well. Fixed in the V2 patch.

Best,
Joe




[Index of Archives]     [Linux IBM ACPI]     [Linux Power Management]     [Linux Kernel]     [Linux Laptop]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]     [Linux Resources]
  Powered by Linux