Skip to content

Commit

Permalink
ACPI: scan: Fix a memory leak in an error handling path
Browse files Browse the repository at this point in the history
[ Upstream commit 0c8bd17 ]

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

Fixes: eb50aaf ("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>
  • Loading branch information
tititiou36 authored and gregkh committed May 19, 2021
1 parent 7225188 commit a7e17a8
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions drivers/acpi/scan.c
Expand Up @@ -701,6 +701,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;
}
Expand Down

0 comments on commit a7e17a8

Please sign in to comment.