summaryrefslogtreecommitdiffstats
path: root/drivers/acpi/dock.c
diff options
context:
space:
mode:
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>2013-06-30 17:50:24 -0400
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2013-07-14 19:33:11 -0400
commita30c4c5ee85680bb66ed8a6c0b0bf4921125c378 (patch)
tree42b772b0ac0c0e5100bd34da0d5fea2a3854232f /drivers/acpi/dock.c
parentf716fc2ac037c45a6c641eb9f20ec602e8d04e14 (diff)
ACPI / dock: Do not leak memory on falilures to add a dock station
The function creating and registering dock station objects, dock_add(), leaks memory if there's an error after it's walked the ACPI namespace calling find_dock_devices(), because it doesn't free the list of dependent devices it's just created in those cases. Fix that issue by adding the missing code to free the list of dependent devices on errors. Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Diffstat (limited to 'drivers/acpi/dock.c')
-rw-r--r--drivers/acpi/dock.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/drivers/acpi/dock.c b/drivers/acpi/dock.c
index a326c7993f4f..3e20b13fa272 100644
--- a/drivers/acpi/dock.c
+++ b/drivers/acpi/dock.c
@@ -115,6 +115,16 @@ add_dock_dependent_device(struct dock_station *ds, acpi_handle handle)
115 return 0; 115 return 0;
116} 116}
117 117
118static void remove_dock_dependent_devices(struct dock_station *ds)
119{
120 struct dock_dependent_device *dd, *aux;
121
122 list_for_each_entry_safe(dd, aux, &ds->dependent_devices, list) {
123 list_del(&dd->list);
124 kfree(dd);
125 }
126}
127
118/** 128/**
119 * dock_init_hotplug - Initialize a hotplug device on a docking station. 129 * dock_init_hotplug - Initialize a hotplug device on a docking station.
120 * @dd: Dock-dependent device. 130 * @dd: Dock-dependent device.
@@ -895,6 +905,7 @@ static int __init dock_add(acpi_handle handle)
895 return 0; 905 return 0;
896 906
897err_rmgroup: 907err_rmgroup:
908 remove_dock_dependent_devices(dock_station);
898 sysfs_remove_group(&dd->dev.kobj, &dock_attribute_group); 909 sysfs_remove_group(&dd->dev.kobj, &dock_attribute_group);
899err_unregister: 910err_unregister:
900 platform_device_unregister(dd); 911 platform_device_unregister(dd);