* [PATCH] pci: pci-tegra: fix a potential NULL pointer dereference
@ 2019-03-14 5:53 Kangjie Lu
0 siblings, 0 replies; only message in thread
From: Kangjie Lu @ 2019-03-14 5:53 UTC (permalink / raw)
To: kjlu
Cc: pakki001, Thierry Reding, Lorenzo Pieralisi, Bjorn Helgaas,
Jonathan Hunter, linux-tegra, linux-pci, linux-kernel
In case __get_free_pages fails and returns NULL, the fix returns
-ENOMEM and releases resources to avoid NULL pointer dereference.
Signed-off-by: Kangjie Lu <kjlu@umn.edu>
---
drivers/pci/controller/pci-tegra.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/drivers/pci/controller/pci-tegra.c b/drivers/pci/controller/pci-tegra.c
index f4f53d092e00..0bdc6ee904f3 100644
--- a/drivers/pci/controller/pci-tegra.c
+++ b/drivers/pci/controller/pci-tegra.c
@@ -1550,6 +1550,12 @@ static int tegra_pcie_msi_setup(struct tegra_pcie *pcie)
/* setup AFI/FPCI range */
msi->pages = __get_free_pages(GFP_KERNEL, 0);
+ if (!msi->pages) {
+ dev_err(dev, "failed to get free pages\n");
+ err = -ENOMEM;
+ goto err;
+ }
+
msi->phys = virt_to_phys((void *)msi->pages);
host->msi = &msi->chip;
--
2.17.1
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2019-03-14 5:53 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-14 5:53 [PATCH] pci: pci-tegra: fix a potential NULL pointer dereference Kangjie Lu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).