mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-05-24 10:39:52 +00:00
platform/x86: wmi: Fix error handling when creating devices
We have two memory leaks. If guid_already_parsed returned true, we leak the wmi_block. If wmi_create_device failed, we leak the device. Simplify the logic and fix both of them. Signed-off-by: Andy Lutomirski <luto@kernel.org> Cc: Andy Lutomirski <luto@amacapital.net> Cc: Mario Limonciello <mario_limonciello@dell.com> Cc: Pali Rohár <pali.rohar@gmail.com> Cc: linux-kernel@vger.kernel.org Cc: platform-driver-x86@vger.kernel.org Cc: linux-acpi@vger.kernel.org Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Signed-off-by: Darren Hart (VMware) <dvhart@infradead.org>
This commit is contained in:
parent
844af950da
commit
a1c31bcd57
1 changed files with 15 additions and 13 deletions
|
@ -757,6 +757,15 @@ static int parse_wdg(struct device *wmi_bus_dev, struct acpi_device *device)
|
||||||
if (debug_dump_wdg)
|
if (debug_dump_wdg)
|
||||||
wmi_dump_wdg(&gblock[i]);
|
wmi_dump_wdg(&gblock[i]);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Some WMI devices, like those for nVidia hooks, have a
|
||||||
|
* duplicate GUID. It's not clear what we should do in this
|
||||||
|
* case yet, so for now, we'll just ignore the duplicate
|
||||||
|
* for device creation.
|
||||||
|
*/
|
||||||
|
if (guid_already_parsed(device, gblock[i].guid))
|
||||||
|
continue;
|
||||||
|
|
||||||
wblock = kzalloc(sizeof(struct wmi_block), GFP_KERNEL);
|
wblock = kzalloc(sizeof(struct wmi_block), GFP_KERNEL);
|
||||||
if (!wblock)
|
if (!wblock)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
@ -764,20 +773,13 @@ static int parse_wdg(struct device *wmi_bus_dev, struct acpi_device *device)
|
||||||
wblock->acpi_device = device;
|
wblock->acpi_device = device;
|
||||||
wblock->gblock = gblock[i];
|
wblock->gblock = gblock[i];
|
||||||
|
|
||||||
/*
|
|
||||||
Some WMI devices, like those for nVidia hooks, have a
|
|
||||||
duplicate GUID. It's not clear what we should do in this
|
|
||||||
case yet, so for now, we'll just ignore the duplicate
|
|
||||||
for device creation.
|
|
||||||
*/
|
|
||||||
if (!guid_already_parsed(device, gblock[i].guid)) {
|
|
||||||
retval = wmi_create_device(wmi_bus_dev, &gblock[i],
|
retval = wmi_create_device(wmi_bus_dev, &gblock[i],
|
||||||
wblock, device);
|
wblock, device);
|
||||||
if (retval) {
|
if (retval) {
|
||||||
|
put_device(&wblock->dev.dev);
|
||||||
wmi_free_devices(device);
|
wmi_free_devices(device);
|
||||||
goto out_free_pointer;
|
goto out_free_pointer;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
list_add_tail(&wblock->list, &wmi_block_list);
|
list_add_tail(&wblock->list, &wmi_block_list);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue