Skip to content

Commit 6238784

Browse files
sungho-furiosabjorn-helgaas
authored andcommitted
PCI/P2PDMA: Fix incorrect pointer usage in devm_kfree() call
The error handling path in pci_p2pdma_add_resource() contains a bug in its `pgmap_free` label. Memory is allocated for the `p2p_pgmap` struct, and the pointer is stored in `p2p_pgmap`. However, the error path calls devm_kfree() with `pgmap`, which is a pointer to a member field within the `p2p_pgmap` struct, not the base pointer of the allocation. Correct the bug by passing the correct base pointer, `p2p_pgmap`, to devm_kfree(). Signed-off-by: Sungho Kim <sungho.kim@furiosa.ai> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com> Reviewed-by: Logan Gunthorpe <logang@deltatee.com> Link: https://patch.msgid.link/20250820105714.2939896-1-sungho.kim@furiosa.ai
1 parent 8f5ae30 commit 6238784

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

drivers/pci/p2pdma.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ int pci_p2pdma_add_resource(struct pci_dev *pdev, int bar, size_t size,
360360
pages_free:
361361
devm_memunmap_pages(&pdev->dev, pgmap);
362362
pgmap_free:
363-
devm_kfree(&pdev->dev, pgmap);
363+
devm_kfree(&pdev->dev, p2p_pgmap);
364364
return error;
365365
}
366366
EXPORT_SYMBOL_GPL(pci_p2pdma_add_resource);

0 commit comments

Comments
 (0)