From: Philipp Zabel
Date: Wed, 22 Oct 2014 14:34:35 +0000 (+0200)
Subject: net: fec: ptp: fix NULL pointer dereference if ptp_clock is not set
X-Git-Tag: firefly_0821_release~176^2~2938^2~45
X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=81f35ffde0e95ee18de83646bbf93dda55d9cc8b;p=firefly-linux-kernel-4.4.55.git
net: fec: ptp: fix NULL pointer dereference if ptp_clock is not set
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
Signed-off-by: David S. Miller
---
diff --git a/drivers/net/ethernet/freescale/fec_main.c b/drivers/net/ethernet/freescale/fec_main.c
index 81b96cf87574..50a851db2852 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;
}