driver core: location: Free struct acpi_pld_info *pld before return false

[ Upstream commit 0d150f967e ]

struct acpi_pld_info *pld should be freed before the return of allocation
failure, to prevent memory leak, add the ACPI_FREE() to fix it.

Fixes: bc443c31de ("driver core: location: Check for allocations failure")
Signed-off-by: Hanjun Guo <guohanjun@huawei.com>
Link: https://lore.kernel.org/r/1669102648-11517-1-git-send-email-guohanjun@huawei.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
Hanjun Guo 2022-11-22 15:37:28 +08:00 committed by Greg Kroah-Hartman
parent d1dbff10c6
commit 8fe72b8f59
1 changed files with 4 additions and 1 deletions

View File

@ -24,8 +24,11 @@ bool dev_add_physical_location(struct device *dev)
dev->physical_location =
kzalloc(sizeof(*dev->physical_location), GFP_KERNEL);
if (!dev->physical_location)
if (!dev->physical_location) {
ACPI_FREE(pld);
return false;
}
dev->physical_location->panel = pld->panel;
dev->physical_location->vertical_position = pld->vertical_position;
dev->physical_location->horizontal_position = pld->horizontal_position;