public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] PCI: endpoint: Fix a double free in __pci_epc_create()
@ 2025-01-07  7:46 Ma Ke
  2025-01-14  0:57 ` Krzysztof Wilczyński
  0 siblings, 1 reply; 5+ messages in thread
From: Ma Ke @ 2025-01-07  7:46 UTC (permalink / raw)
  To: lpieralisi, kw, mani, kishon, bhelgaas, jpinto
  Cc: linux-pci, linux-kernel, Ma Ke, stable

The put_device(&epc->dev) call will trigger pci_epc_release() which
frees "epc" so the kfree(epc) on the next line is a double free.

Found by code review.

Cc: stable@vger.kernel.org
Fixes: 5e8cb4033807 ("PCI: endpoint: Add EP core layer to enable EP controller and EP functions")
Signed-off-by: Ma Ke <make24@iscas.ac.cn>
---
 drivers/pci/endpoint/pci-epc-core.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/pci/endpoint/pci-epc-core.c b/drivers/pci/endpoint/pci-epc-core.c
index 46c9a5c3ca14..652350f054cf 100644
--- a/drivers/pci/endpoint/pci-epc-core.c
+++ b/drivers/pci/endpoint/pci-epc-core.c
@@ -818,7 +818,6 @@ __pci_epc_create(struct device *dev, const struct pci_epc_ops *ops,
 
 put_dev:
 	put_device(&epc->dev);
-	kfree(epc);
 
 err_ret:
 	return ERR_PTR(ret);
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread
* [PATCH] PCI: endpoint: Fix a double free in __pci_epc_create()
@ 2025-01-02  9:30 Ma Ke
  2025-01-03 10:28 ` Markus Elfring
  0 siblings, 1 reply; 5+ messages in thread
From: Ma Ke @ 2025-01-02  9:30 UTC (permalink / raw)
  To: lpieralisi, kw, mani, kishon, bhelgaas, jpinto
  Cc: linux-pci, linux-kernel, Ma Ke, stable

The put_device(&epc->dev) call will trigger pci_epc_release() which
frees "epc" so the kfree(epc) on the next line is a double free.

Found by code review.

Cc: stable@vger.kernel.org
Fixes: 5e8cb4033807 ("PCI: endpoint: Add EP core layer to enable EP controller and EP functions")
Signed-off-by: Ma Ke <make_ruc2021@163.com>
---
 drivers/pci/endpoint/pci-epc-core.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/pci/endpoint/pci-epc-core.c b/drivers/pci/endpoint/pci-epc-core.c
index 46c9a5c3ca14..652350f054cf 100644
--- a/drivers/pci/endpoint/pci-epc-core.c
+++ b/drivers/pci/endpoint/pci-epc-core.c
@@ -818,7 +818,6 @@ __pci_epc_create(struct device *dev, const struct pci_epc_ops *ops,
 
 put_dev:
 	put_device(&epc->dev);
-	kfree(epc);
 
 err_ret:
 	return ERR_PTR(ret);
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2025-02-20 16:23 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-01-07  7:46 [PATCH] PCI: endpoint: Fix a double free in __pci_epc_create() Ma Ke
2025-01-14  0:57 ` Krzysztof Wilczyński
2025-02-20 16:23   ` Krzysztof Wilczyński
  -- strict thread matches above, loose matches on Subject: below --
2025-01-02  9:30 Ma Ke
2025-01-03 10:28 ` Markus Elfring

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox