Linux PCI subsystem development
 help / color / mirror / Atom feed
* [PATCH] PCI: iproc: fix kernel crash if dev->of_node not defined
@ 2017-01-13  0:20 Abylay Ospan
  2017-01-13  0:22 ` Florian Fainelli
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Abylay Ospan @ 2017-01-13  0:20 UTC (permalink / raw)
  To: Bjorn Helgaas, Ray Jui, Scott Branden, Jon Mason,
	bcm-kernel-feedback-list, linux-pci, linux-arm-kernel,
	linux-kernel
  Cc: Abylay Ospan

pcie->dev->of_node not always defined (NULL) and can cause crash:

[   19.053195] Unable to handle kernel NULL pointer dereference at
virtual address 00000020
[<c0b0370c>] (of_n_addr_cells) from [<c06599c4>]
(iproc_pcie_setup+0x30c/0xce0)

this patch adds sanity check to prevent crash.

Signed-off-by: Abylay Ospan <aospan@netup.ru>
---
 drivers/pci/host/pcie-iproc.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/pci/host/pcie-iproc.c b/drivers/pci/host/pcie-iproc.c
index 3ebc025..f2836a9 100644
--- a/drivers/pci/host/pcie-iproc.c
+++ b/drivers/pci/host/pcie-iproc.c
@@ -952,6 +952,9 @@ static int pci_dma_range_parser_init(struct of_pci_range_parser *parser,
 	const int na = 3, ns = 2;
 	int rlen;
 
+	if (!node)
+		return -ENOENT;
+
 	parser->node = node;
 	parser->pna = of_n_addr_cells(node);
 	parser->np = parser->pna + na + ns;
-- 
2.7.4


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2017-01-28 20:44 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-01-13  0:20 [PATCH] PCI: iproc: fix kernel crash if dev->of_node not defined Abylay Ospan
2017-01-13  0:22 ` Florian Fainelli
2017-01-13  0:48   ` Ray Jui
2017-01-13  1:20     ` Florian Fainelli
2017-01-13  4:55       ` Abylay Ospan
2017-01-16 22:47         ` Florian Fainelli
2017-01-13  5:58   ` Abylay Ospan
2017-01-13  0:45 ` Ray Jui
2017-01-28 20:44 ` Bjorn Helgaas

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox