ACPI: scan: Fix a memory leak in an error handling path
authorChristophe JAILLET <christophe.jaillet@wanadoo.fr>
Sat, 8 May 2021 07:23:09 +0000 (09:23 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 22 May 2021 08:40:32 +0000 (10:40 +0200)
[ Upstream commit 0c8bd174f0fc131bc9dfab35cd8784f59045da87 ]

If 'acpi_device_set_name()' fails, we must free
'acpi_device_bus_id->bus_id' or there is a (potential) memory leak.

Fixes: eb50aaf960e3 ("ACPI: scan: Use unique number for instance_no")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/acpi/scan.c

index d749fe20fbfc546a1a1a35737bdfff1064bf3ebd..89ce7b14a1660ce3b4aa9787694f5a6f6f59a560 100644 (file)
@@ -704,6 +704,7 @@ int acpi_device_add(struct acpi_device *device,
 
                result = acpi_device_set_name(device, acpi_device_bus_id);
                if (result) {
+                       kfree_const(acpi_device_bus_id->bus_id);
                        kfree(acpi_device_bus_id);
                        goto err_unlock;
                }