diff mbox series

ptp_qoriq: fix NULL access if ptp dt node missing

Message ID 20190509030845.36713-1-yangbo.lu@nxp.com
State Accepted
Delegated to: David Miller
Headers show
Series ptp_qoriq: fix NULL access if ptp dt node missing | expand

Commit Message

Yangbo Lu May 9, 2019, 3:07 a.m. UTC
From: Claudiu Manoil <claudiu.manoil@nxp.com>

Make sure ptp dt node exists before accessing it in case
of NULL pointer call trace.

Signed-off-by: Claudiu Manoil <claudiu.manoil@nxp.com>
Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>
---
 drivers/ptp/ptp_qoriq.c | 3 +++
 1 file changed, 3 insertions(+)

Comments

Richard Cochran May 9, 2019, 3:57 a.m. UTC | #1
On Thu, May 09, 2019 at 03:07:12AM +0000, Y.b. Lu wrote:
> From: Claudiu Manoil <claudiu.manoil@nxp.com>
> 
> Make sure ptp dt node exists before accessing it in case
> of NULL pointer call trace.
> 
> Signed-off-by: Claudiu Manoil <claudiu.manoil@nxp.com>
> Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>

Acked-by: Richard Cochran <richardcochran@gmail.com>
David Miller May 9, 2019, 4:19 p.m. UTC | #2
From: "Y.b. Lu" <yangbo.lu@nxp.com>
Date: Thu, 9 May 2019 03:07:12 +0000

> From: Claudiu Manoil <claudiu.manoil@nxp.com>
> 
> Make sure ptp dt node exists before accessing it in case
> of NULL pointer call trace.
> 
> Signed-off-by: Claudiu Manoil <claudiu.manoil@nxp.com>
> Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>

Applied, thanks.
diff mbox series

Patch

diff --git a/drivers/ptp/ptp_qoriq.c b/drivers/ptp/ptp_qoriq.c
index 53775362aac6..e10642403b25 100644
--- a/drivers/ptp/ptp_qoriq.c
+++ b/drivers/ptp/ptp_qoriq.c
@@ -467,6 +467,9 @@  int ptp_qoriq_init(struct ptp_qoriq *ptp_qoriq, void __iomem *base,
 	unsigned long flags;
 	u32 tmr_ctrl;
 
+	if (!node)
+		return -ENODEV;
+
 	ptp_qoriq->base = base;
 	ptp_qoriq->caps = *caps;