]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
PCI: Fix reference leak in pci_alloc_child_bus()
authorMa Ke <make24@iscas.ac.cn>
Sun, 2 Feb 2025 06:23:57 +0000 (14:23 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 2 May 2025 05:44:06 +0000 (07:44 +0200)
commit40c4c64507fe532e991a29a592abd82334664f0e
tree9a6e1d7f841ea6e935fa1e7b605588fc74ff28bf
parent8730a3c6f0f1291cb009825289fd4c9e5cd2402b
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: 4f535093cf8f ("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>
drivers/pci/probe.c