[<prev] [next>] [day] [month] [year] [list]
Message-Id: <20190314055347.3519-1-kjlu@umn.edu>
Date: Thu, 14 Mar 2019 00:53:47 -0500
From: Kangjie Lu <kjlu@....edu>
To: kjlu@....edu
Cc: pakki001@....edu, Thierry Reding <thierry.reding@...il.com>,
Lorenzo Pieralisi <lorenzo.pieralisi@....com>,
Bjorn Helgaas <bhelgaas@...gle.com>,
Jonathan Hunter <jonathanh@...dia.com>,
linux-tegra@...r.kernel.org, linux-pci@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: [PATCH] pci: pci-tegra: fix a potential NULL pointer dereference
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@....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
Powered by blists - more mailing lists