* [PATCH] net: fec: ptp: fix NULL pointer dereference if ptp_clock is not set
@ 2014-10-22 14:34 Philipp Zabel
2014-10-22 21:48 ` David Miller
0 siblings, 1 reply; 2+ messages in thread
From: Philipp Zabel @ 2014-10-22 14:34 UTC (permalink / raw)
To: David S. Miller, Luwei Zhou; +Cc: netdev, Philipp Zabel
Since commit 278d24047891 (net: fec: ptp: Enable PPS output based on ptp clock)
fec_enet_interrupt calls fec_ptp_check_pps_event unconditionally, which calls
into ptp_clock_event. If fep->ptp_clock is NULL, ptp_clock_event tries to
dereference the NULL pointer.
Since on i.MX53 fep->bufdesc_ex is not set, fec_ptp_init is never called,
and fep->ptp_clock is NULL, which reliably causes a kernel panic.
This patch adds a check for fep->ptp_clock == NULL in fec_enet_interrupt.
Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
---
drivers/net/ethernet/freescale/fec_main.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/freescale/fec_main.c b/drivers/net/ethernet/freescale/fec_main.c
index 81b96cf..50a851d 100644
--- a/drivers/net/ethernet/freescale/fec_main.c
+++ b/drivers/net/ethernet/freescale/fec_main.c
@@ -1581,7 +1581,8 @@ fec_enet_interrupt(int irq, void *dev_id)
complete(&fep->mdio_done);
}
- fec_ptp_check_pps_event(fep);
+ if (fep->ptp_clock)
+ fec_ptp_check_pps_event(fep);
return ret;
}
--
2.1.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] net: fec: ptp: fix NULL pointer dereference if ptp_clock is not set
2014-10-22 14:34 [PATCH] net: fec: ptp: fix NULL pointer dereference if ptp_clock is not set Philipp Zabel
@ 2014-10-22 21:48 ` David Miller
0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2014-10-22 21:48 UTC (permalink / raw)
To: p.zabel; +Cc: b45643, netdev
From: Philipp Zabel <p.zabel@pengutronix.de>
Date: Wed, 22 Oct 2014 16:34:35 +0200
> Since commit 278d24047891 (net: fec: ptp: Enable PPS output based on ptp clock)
> fec_enet_interrupt calls fec_ptp_check_pps_event unconditionally, which calls
> into ptp_clock_event. If fep->ptp_clock is NULL, ptp_clock_event tries to
> dereference the NULL pointer.
> Since on i.MX53 fep->bufdesc_ex is not set, fec_ptp_init is never called,
> and fep->ptp_clock is NULL, which reliably causes a kernel panic.
>
> This patch adds a check for fep->ptp_clock == NULL in fec_enet_interrupt.
>
> Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
Applied, thank you.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2014-10-22 21:48 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-10-22 14:34 [PATCH] net: fec: ptp: fix NULL pointer dereference if ptp_clock is not set Philipp Zabel
2014-10-22 21:48 ` David Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).