PCI: endpoint: Fix a double free in __pci_epc_create()
Subsystems (3)
PATCH 1/1 PCI: endpoint: Fix a double free in __pci_epc_create()
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.
--- drivers/pci/endpoint/pci-epc-core.c | 1 - 1 file changed, 1 deletion(-)
drivers/pci/endpoint/pci-epc-core.c +0 -1
@@ -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);
Signature · 1 line
2.25.1
Hello,
Quoted 8 lines
The
put_device(&epc->dev)call will triggerpci_epc_release()which frees "epc" so the kfree(epc) on the next line is a double free.Found by code review.
Fixes 5e8cb4033807 ("PCI: endpoint: Add EP core layer to enable EP controller and EP functions")Signed-off-by Ma Ke <[email protected]>
Which kernel release did you review? I don't see this kfree() when looking at the current code base per:
https://elixir.bootlin.com/linux/v6.13-rc1/source/drivers/pci/endpoint/pci-epc-core.c#L956-L1020
Krzysztof
Hello,
Quoted 4 lines
Quoted 4 lines
The
put_device(&epc->dev)call will triggerpci_epc_release()which frees "epc" so the kfree(epc) on the next line is a double free.Found by code review.
[...]
Quoted 4 lines
Which kernel release did you review? I don't see this
kfree()when looking at the current code base per:https://elixir.bootlin.com/linux/v6.13-rc1/source/drivers/pci/endpoint/pci-epc-core.c#L956-L1020
I will answer my own question. This surplus kfree() has already been removed as part of the following commit:
c9501d268944 ("PCI: endpoint: Fix double free in __pci_epc_create()")
Nevertheless, thank you for the patch.
Krzysztof