lkml.org 
[lkml]   [2019]   [Mar]   [14]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH] pci: pci-tegra: fix a potential NULL pointer dereference
Date
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
\
 
 \ /
  Last update: 2019-03-14 06:54    [W:0.028 / U:0.036 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site