mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-05 19:31:57 -04:00
PCI: Fix reference leak in pci_alloc_child_bus()
commit 1f2768b6a3ee77a295106e3a5d68458064923ede upstream.
If device_register(&child->dev) fails, call put_device() to explicitly
release child->dev, per the comment at device_register().
Found by code review.
Link: https://lore.kernel.org/r/20250202062357.872971-1-make24@iscas.ac.cn
Fixes: 4f535093cf ("PCI: Put pci_dev in device tree as early as possible")
Signed-off-by: Ma Ke <make24@iscas.ac.cn>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Cc: stable@vger.kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
4ddd8e34c5
commit
7b4487b8c6
1 changed files with 4 additions and 1 deletions
|
|
@ -1041,7 +1041,10 @@ static struct pci_bus *pci_alloc_child_bus(struct pci_bus *parent,
|
|||
add_dev:
|
||||
pci_set_bus_msi_domain(child);
|
||||
ret = device_register(&child->dev);
|
||||
WARN_ON(ret < 0);
|
||||
if (WARN_ON(ret < 0)) {
|
||||
put_device(&child->dev);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
pcibios_add_bus(child);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue