]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
platform/x86: panasonic-laptop: Fix sysfs group leak in error path
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>
Tue, 20 Jan 2026 15:43:44 +0000 (16:43 +0100)
committerIlpo Järvinen <ilpo.jarvinen@linux.intel.com>
Mon, 26 Jan 2026 14:38:04 +0000 (16:38 +0200)
The acpi_pcc_hotkey_add() error path leaks sysfs group pcc_attr_group
if platform_device_register_simple() fails for the "panasonic" platform
device.

Address this by making it call sysfs_remove_group() in that case for
the group in question.

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Link: https://patch.msgid.link/3398370.44csPzL39Z@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 255317e6fec88153ca89c307da8bec3e817d78cb..937f1a5b78edfbc97c28f7d4979647945bbf38c7 100644 (file)
@@ -1089,7 +1089,7 @@ static int acpi_pcc_hotkey_add(struct acpi_device *device)
                        PLATFORM_DEVID_NONE, NULL, 0);
                if (IS_ERR(pcc->platform)) {
                        result = PTR_ERR(pcc->platform);
-                       goto out_backlight;
+                       goto out_sysfs;
                }
                result = device_create_file(&pcc->platform->dev,
                        &dev_attr_cdpower);
@@ -1105,6 +1105,8 @@ static int acpi_pcc_hotkey_add(struct acpi_device *device)
 
 out_platform:
        platform_device_unregister(pcc->platform);
+out_sysfs:
+       sysfs_remove_group(&device->dev.kobj, &pcc_attr_group);
 out_backlight:
        backlight_device_unregister(pcc->backlight);
 out_input: