diff mbox series

[-next,1/2] PCI: fix possible memory leak in error case in pci_setup_device()

Message ID 20220817084444.2876059-1-yangyingliang@huawei.com (mailing list archive)
State New, archived
Delegated to: Bjorn Helgaas
Headers show
Series [-next,1/2] PCI: fix possible memory leak in error case in pci_setup_device() | expand

Commit Message

Yang Yingliang Aug. 17, 2022, 8:44 a.m. UTC
If pci_setup_device() fails, the device name need be freed
to avoid memory leak.

Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
---
 drivers/pci/probe.c | 1 +
 1 file changed, 1 insertion(+)
diff mbox series

Patch

diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index c5286b027f00..0e947f24153e 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -1976,6 +1976,7 @@  int pci_setup_device(struct pci_dev *dev)
 	default:				    /* unknown header */
 		pci_err(dev, "unknown header type %02x, ignoring device\n",
 			dev->hdr_type);
+		kfree_const(dev->dev.kobj.name);
 		pci_release_of_node(dev);
 		return -EIO;