[PATCH v1 01/10] platform/x86: classmate-laptop: Address memory leaks on driver removal
From: Rafael J. Wysocki
Date: Thu May 07 2026 - 16:15:16 EST
From: "Rafael J. Wysocki" <rafael.j.wysocki@xxxxxxxxx>
Update cmpc_accel_remove_v4() and cmpc_accel_remove() to free memory
allocated in cmpc_accel_add_v4() and cmpc_accel_add(), respectively.
Fixes: 529aa8cb0a59 ("classmate-laptop: add support for Classmate PC ACPI devices")
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@xxxxxxxxx>
---
drivers/platform/x86/classmate-laptop.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/drivers/platform/x86/classmate-laptop.c b/drivers/platform/x86/classmate-laptop.c
index e6eed3d65580..218834ddddc3 100644
--- a/drivers/platform/x86/classmate-laptop.c
+++ b/drivers/platform/x86/classmate-laptop.c
@@ -441,9 +441,13 @@ static int cmpc_accel_add_v4(struct acpi_device *acpi)
static void cmpc_accel_remove_v4(struct acpi_device *acpi)
{
+ struct input_dev *inputdev = dev_get_drvdata(&acpi->dev);
+ struct cmpc_accel *accel = dev_get_drvdata(&inputdev->dev);
+
device_remove_file(&acpi->dev, &cmpc_accel_sensitivity_attr_v4);
device_remove_file(&acpi->dev, &cmpc_accel_g_select_attr_v4);
cmpc_remove_acpi_notify_device(acpi);
+ kfree(accel);
}
static SIMPLE_DEV_PM_OPS(cmpc_accel_pm, cmpc_accel_suspend_v4,
@@ -680,8 +684,12 @@ static int cmpc_accel_add(struct acpi_device *acpi)
static void cmpc_accel_remove(struct acpi_device *acpi)
{
+ struct input_dev *inputdev = dev_get_drvdata(&acpi->dev);
+ struct cmpc_accel *accel = dev_get_drvdata(&inputdev->dev);
+
device_remove_file(&acpi->dev, &cmpc_accel_sensitivity_attr);
cmpc_remove_acpi_notify_device(acpi);
+ kfree(accel);
}
static const struct acpi_device_id cmpc_accel_device_ids[] = {