net: fec_ptp: add clock rate zero check
commitcb3cefe3f3upstream. Add clock rate zero check to fix coverity issue of "divide by 0". Fixes: commit85bd1798b2("net: fec: fix spin_lock dead lock") Signed-off-by: Fugang Duan <fugang.duan@nxp.com> Signed-off-by: Joakim Zhang <qiangqing.zhang@nxp.com> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
1af3a8e91f
commit
4f6e7098f1
@@ -602,6 +602,10 @@ void fec_ptp_init(struct platform_device *pdev, int irq_idx)
|
|||||||
fep->ptp_caps.enable = fec_ptp_enable;
|
fep->ptp_caps.enable = fec_ptp_enable;
|
||||||
|
|
||||||
fep->cycle_speed = clk_get_rate(fep->clk_ptp);
|
fep->cycle_speed = clk_get_rate(fep->clk_ptp);
|
||||||
|
if (!fep->cycle_speed) {
|
||||||
|
fep->cycle_speed = NSEC_PER_SEC;
|
||||||
|
dev_err(&fep->pdev->dev, "clk_ptp clock rate is zero\n");
|
||||||
|
}
|
||||||
fep->ptp_inc = NSEC_PER_SEC / fep->cycle_speed;
|
fep->ptp_inc = NSEC_PER_SEC / fep->cycle_speed;
|
||||||
|
|
||||||
spin_lock_init(&fep->tmreg_lock);
|
spin_lock_init(&fep->tmreg_lock);
|
||||||
|
|||||||
Reference in New Issue
Block a user