Commit f4db1b2c authored by Ma Ke's avatar Ma Ke Committed by Greg Kroah-Hartman
Browse files

PCI: Fix reference leak in pci_register_host_bridge()

[ Upstream commit 804443c1 ]

If device_register() fails, call put_device() to give up the reference to
avoid a memory leak, per the comment at device_register().

Found by code review.

Link: https://lore.kernel.org/r/20250225021440.3130264-1-make24@iscas.ac.cn


Fixes: 37d6a0a6 ("PCI: Add pci_register_host_bridge() interface")
Signed-off-by: default avatarMa Ke <make24@iscas.ac.cn>
[bhelgaas: squash Dan Carpenter's double free fix from
https://lore.kernel.org/r/db806a6c-a91b-4e5a-a84b-6b7e01bdac85@stanley.mountain

]
Signed-off-by: default avatarBjorn Helgaas <bhelgaas@google.com>
Cc: stable@vger.kernel.org
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
parent f8b6bd6c
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment