diff mbox

Pci: host - Fix possible NULL derefrence.

Message ID 1485751775-29126-1-git-send-email-shailendra.v@samsung.com
State New, archived
Headers show

Commit Message

shailendra.v@samsung.com Jan. 30, 2017, 4:49 a.m. UTC
of_match_device could return NULL, and so can cause a NULL
pointer dereference later.

Signed-off-by: Shailendra Verma <shailendra.v@samsung.com>
---
 drivers/pci/host/pcie-hisi.c |    4 ++++
 1 file changed, 4 insertions(+)
diff mbox

Patch

diff --git a/drivers/pci/host/pcie-hisi.c b/drivers/pci/host/pcie-hisi.c
index 56154c2..3256f8f 100644
--- a/drivers/pci/host/pcie-hisi.c
+++ b/drivers/pci/host/pcie-hisi.c
@@ -174,6 +174,10 @@  static int hisi_pcie_probe(struct platform_device *pdev)
 	driver = dev->driver;
 
 	match = of_match_device(driver->of_match_table, dev);
+	if (!match) {
+		dev_err(dev, "Error: No device match found\n");
+		return -ENODEV;
+	}
 	hisi_pcie->soc_ops = (struct pcie_soc_ops *) match->data;
 
 	hisi_pcie->subctrl =