diff options
author | Kangjie Lu <kjlu@umn.edu> | 2019-03-15 03:29:43 -0400 |
---|---|---|
committer | Lorenzo Pieralisi <lorenzo.pieralisi@arm.com> | 2019-04-04 06:49:05 -0400 |
commit | f0d14edd2ba43b995bef4dd5da5ffe0ae19321a1 (patch) | |
tree | 9b6994ac065b5caea88612d052c1215fe7fd74bc | |
parent | 954b4b752a4c4e963b017ed8cef4c453c5ed308d (diff) |
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) | |||
929 | 929 | ||
930 | /* setup MSI data target */ | 930 | /* setup MSI data target */ |
931 | msi->pages = __get_free_pages(GFP_KERNEL, 0); | 931 | msi->pages = __get_free_pages(GFP_KERNEL, 0); |
932 | if (!msi->pages) { | ||
933 | err = -ENOMEM; | ||
934 | goto err; | ||
935 | } | ||
932 | base = virt_to_phys((void *)msi->pages); | 936 | base = virt_to_phys((void *)msi->pages); |
933 | 937 | ||
934 | rcar_pci_write_reg(pcie, lower_32_bits(base) | MSIFE, PCIEMSIALR); | 938 | rcar_pci_write_reg(pcie, lower_32_bits(base) | MSIFE, PCIEMSIALR); |