Skip to content

Commit

Permalink
net: fec_ptp: add clock rate zero check
Browse files Browse the repository at this point in the history
Add clock rate zero check to fix coverity issue of "divide by 0".

Fixes: commit 85bd179 ("net: fec: fix spin_lock dead lock")
Signed-off-by: Fugang Duan <[email protected]>
Signed-off-by: Joakim Zhang <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
fugangduan authored and davem330 committed Jun 16, 2021
1 parent 56b786d commit cb3cefe
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions drivers/net/ethernet/freescale/fec_ptp.c
Original file line number Diff line number Diff line change
Expand Up @@ -604,6 +604,10 @@ void fec_ptp_init(struct platform_device *pdev, int irq_idx)
fep->ptp_caps.enable = fec_ptp_enable;

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;

spin_lock_init(&fep->tmreg_lock);
Expand Down

0 comments on commit cb3cefe

Please sign in to comment.