Skip to content

Commit cbefe2f

Browse files
Tropicaokuba-moo
authored andcommitted
net: stmmac: make sure that ptp_rate is not 0 before configuring EST
If the ptp_rate recorded earlier in the driver happens to be 0, this bogus value will propagate up to EST configuration, where it will trigger a division by 0. Prevent this division by 0 by adding the corresponding check and error code. Suggested-by: Maxime Chevallier <maxime.chevallier@bootlin.com> Signed-off-by: Alexis Lothoré <alexis.lothore@bootlin.com> Fixes: 8572aec ("net: stmmac: Add basic EST support for XGMAC") Link: https://patch.msgid.link/20250529-stmmac_tstamp_div-v4-2-d73340a794d5@bootlin.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1 parent 030ce91 commit cbefe2f

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

drivers/net/ethernet/stmicro/stmmac/stmmac_est.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,11 @@ static int est_configure(struct stmmac_priv *priv, struct stmmac_est *cfg,
3232
int i, ret = 0;
3333
u32 ctrl;
3434

35+
if (!ptp_rate) {
36+
netdev_warn(priv->dev, "Invalid PTP rate");
37+
return -EINVAL;
38+
}
39+
3540
ret |= est_write(est_addr, EST_BTR_LOW, cfg->btr[0], false);
3641
ret |= est_write(est_addr, EST_BTR_HIGH, cfg->btr[1], false);
3742
ret |= est_write(est_addr, EST_TER, cfg->ter, false);

0 commit comments

Comments
 (0)