Skip to content

Commit 3d0e610

Browse files
rafaeljwgregkh
authored andcommitted
platform/x86: panasonic-laptop: Fix OPTD notifier registration and cleanup
[ Upstream commit 8baeff2 ] 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: d5a81d8 ("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> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent fed8b8f commit 3d0e610

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

drivers/platform/x86/panasonic-laptop.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1081,9 +1081,10 @@ static int acpi_pcc_hotkey_add(struct acpi_device *device)
10811081
}
10821082
result = device_create_file(&pcc->platform->dev,
10831083
&dev_attr_cdpower);
1084-
pcc_register_optd_notifier(pcc, "\\_SB.PCI0.EHCI.ERHB.OPTD");
10851084
if (result)
10861085
goto out_platform;
1086+
1087+
pcc_register_optd_notifier(pcc, "\\_SB.PCI0.EHCI.ERHB.OPTD");
10871088
} else {
10881089
pcc->platform = NULL;
10891090
}
@@ -1117,10 +1118,10 @@ static void acpi_pcc_hotkey_remove(struct acpi_device *device)
11171118
i8042_remove_filter(panasonic_i8042_filter);
11181119

11191120
if (pcc->platform) {
1121+
pcc_unregister_optd_notifier(pcc, "\\_SB.PCI0.EHCI.ERHB.OPTD");
11201122
device_remove_file(&pcc->platform->dev, &dev_attr_cdpower);
11211123
platform_device_unregister(pcc->platform);
11221124
}
1123-
pcc_unregister_optd_notifier(pcc, "\\_SB.PCI0.EHCI.ERHB.OPTD");
11241125

11251126
sysfs_remove_group(&device->dev.kobj, &pcc_attr_group);
11261127

0 commit comments

Comments
 (0)