]> git.proxmox.com Git - mirror_ubuntu-hirsute-kernel.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)
committerSeth Forshee <seth.forshee@canonical.com>
Thu, 8 Apr 2021 20:42:40 +0000 (15:42 -0500)
commit8d46acd3deae8b85d9e049ffb6650f2ec6bccacd
tree2eb72c113c0fda39d30e1ed59d2b2cff8287a436
parent0851e72105b01e31740cdda1eb072d0f287405a0
ACPI: scan: Rearrange memory allocation in acpi_device_add()

BugLink: https://bugs.launchpad.net/bugs/1922601
[ 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>
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
drivers/acpi/scan.c