diff options
author | Kangjie Lu <kjlu@umn.edu> | 2019-03-15 02:29:43 -0500 |
---|---|---|
committer | Lorenzo Pieralisi <lorenzo.pieralisi@arm.com> | 2019-04-04 11:49:05 +0100 |
commit | f0d14edd2ba43b995bef4dd5da5ffe0ae19321a1 (patch) | |
tree | 9b6994ac065b5caea88612d052c1215fe7fd74bc | |
parent | 954b4b752a4c4e963b017ed8cef4c453c5ed308d (diff) | |
download | linux-f0d14edd2ba43b995bef4dd5da5ffe0ae19321a1.tar.gz linux-f0d14edd2ba43b995bef4dd5da5ffe0ae19321a1.tar.bz2 linux-f0d14edd2ba43b995bef4dd5da5ffe0ae19321a1.zip |
PCI: rcar: Fix a potential NULL pointer dereference
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 <kjlu@umn.edu>
Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Reviewed-by: Ulrich Hecht <uli+renesas@fpond.eu>
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Reviewed-by: Simon Horman <horms+renesas@verge.net.au>
-rw-r--r-- | drivers/pci/controller/pcie-rcar.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/drivers/pci/controller/pcie-rcar.c b/drivers/pci/controller/pcie-rcar.c index a25527185bf1..0004b6457124 100644 --- a/drivers/pci/controller/pcie-rcar.c +++ b/drivers/pci/controller/pcie-rcar.c @@ -929,6 +929,10 @@ static int rcar_pcie_enable_msi(struct rcar_pcie *pcie) /* setup MSI data target */ msi->pages = __get_free_pages(GFP_KERNEL, 0); + if (!msi->pages) { + err = -ENOMEM; + goto err; + } base = virt_to_phys((void *)msi->pages); rcar_pci_write_reg(pcie, lower_32_bits(base) | MSIFE, PCIEMSIALR); |