]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
ACPI: scan: Rearrange memory allocation in acpi_device_add()
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>
Thu, 14 Jan 2021 18:46:47 +0000 (19:46 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 30 Mar 2021 12:35:28 +0000 (14:35 +0200)
commitb382f9d616090d3d8cfe19b9568a2c1c6f4bce55
tree319ca01c36e9ff35fa3e2008b793395b76acd727
parentcc578c3e612bd4790b5fb78124088c07cf059b33
ACPI: scan: Rearrange memory allocation in acpi_device_add()

[ Upstream commit c1013ff7a5472db637c56bb6237f8343398c03a7 ]

The upfront allocation of new_bus_id is done to avoid allocating
memory under acpi_device_lock, but it doesn't really help,
because (1) it leads to many unnecessary memory allocations for
_ADR devices, (2) kstrdup_const() is run under that lock anyway and
(3) it complicates the code.

Rearrange acpi_device_add() to allocate memory for a new struct
acpi_device_bus_id instance only when necessary, eliminate a redundant
local variable from it and reduce the number of labels in there.

No intentional functional impact.

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/acpi/scan.c