Skip to content

Commit fd21793

Browse files
kengitergregkh
authored andcommitted
PCI: rcar: Fix a potential NULL pointer dereference
[ Upstream commit f0d14ed ] In case __get_free_pages() fails and returns NULL, fix the return value to -ENOMEM and release resources to avoid dereferencing a NULL pointer. Signed-off-by: Kangjie Lu <[email protected]> Signed-off-by: Lorenzo Pieralisi <[email protected]> Reviewed-by: Ulrich Hecht <[email protected]> Reviewed-by: Geert Uytterhoeven <[email protected]> Reviewed-by: Simon Horman <[email protected]> Signed-off-by: Sasha Levin <[email protected]>
1 parent 7fddf0c commit fd21793

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

drivers/pci/host/pcie-rcar.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -886,6 +886,10 @@ static int rcar_pcie_enable_msi(struct rcar_pcie *pcie)
886886

887887
/* setup MSI data target */
888888
msi->pages = __get_free_pages(GFP_KERNEL, 0);
889+
if (!msi->pages) {
890+
err = -ENOMEM;
891+
goto err;
892+
}
889893
base = virt_to_phys((void *)msi->pages);
890894

891895
rcar_pci_write_reg(pcie, base | MSIFE, PCIEMSIALR);

0 commit comments

Comments
 (0)