]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
platform/x86: panasonic-laptop: Fix OPTD notifier registration and cleanup
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>
Fri, 20 Mar 2026 10:31:54 +0000 (11:31 +0100)
committerIlpo Järvinen <ilpo.jarvinen@linux.intel.com>
Mon, 23 Mar 2026 09:33:53 +0000 (11:33 +0200)
An ACPI notify handler is leaked if device_create_file() returns an
error in acpi_pcc_hotkey_add().

Also, it is pointless to call pcc_unregister_optd_notifier() in
acpi_pcc_hotkey_remove() if pcc->platform is NULL and it is better
to arrange the cleanup code in that function in the same order as
the rollback code in acpi_pcc_hotkey_add().

Address the above by placing the pcc_register_optd_notifier() call in
acpi_pcc_hotkey_add() after the device_create_file() return value
check and placing the pcc_unregister_optd_notifier() call in
acpi_pcc_hotkey_remove() right before the device_remove_file() call.

Fixes: d5a81d8e864b ("platform/x86: panasonic-laptop: Add support for optical driver power in Y and W series")
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Link: https://patch.msgid.link/2411055.ElGaqSPkdT@rafael.j.wysocki
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
drivers/platform/x86/panasonic-laptop.c

index a481f2602ce3e9017942c08e73966d2090c56fe0..56b4e61d7e5c88016341f29e88f5328f94f80c9f 100644 (file)
@@ -1090,9 +1090,10 @@ static int acpi_pcc_hotkey_add(struct acpi_device *device)
                }
                result = device_create_file(&pcc->platform->dev,
                        &dev_attr_cdpower);
-               pcc_register_optd_notifier(pcc, "\\_SB.PCI0.EHCI.ERHB.OPTD");
                if (result)
                        goto out_platform;
+
+               pcc_register_optd_notifier(pcc, "\\_SB.PCI0.EHCI.ERHB.OPTD");
        } else {
                pcc->platform = NULL;
        }
@@ -1126,10 +1127,10 @@ static void acpi_pcc_hotkey_remove(struct acpi_device *device)
        i8042_remove_filter(panasonic_i8042_filter);
 
        if (pcc->platform) {
+               pcc_unregister_optd_notifier(pcc, "\\_SB.PCI0.EHCI.ERHB.OPTD");
                device_remove_file(&pcc->platform->dev, &dev_attr_cdpower);
                platform_device_unregister(pcc->platform);
        }
-       pcc_unregister_optd_notifier(pcc, "\\_SB.PCI0.EHCI.ERHB.OPTD");
 
        sysfs_remove_group(&device->dev.kobj, &pcc_attr_group);