[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20211202223729.134238-1-amhamza.mgc@gmail.com>
Date: Fri, 3 Dec 2021 03:37:29 +0500
From: Ameer Hamza <amhamza.mgc@...il.com>
To: davem@...emloft.net, kuba@...nel.org, mcoquelin.stm32@...il.com,
netdev@...r.kernel.org, linux-kernel@...r.kernel.org
Cc: amhamza.mgc@...il.com
Subject: [PATCH] net: stmmac: Fix possible division by zero
Fix for divide by zero error reported by Coverity.
Addresses-Coverity: 1494557 ("Division or modulo by zero")
Signed-off-by: Ameer Hamza <amhamza.mgc@...il.com>
---
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index da8306f60730..f44400323407 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -863,7 +863,7 @@ int stmmac_init_tstamp_counter(struct stmmac_priv *priv, u32 systime_flags)
stmmac_config_sub_second_increment(priv, priv->ptpaddr,
priv->plat->clk_ptp_rate,
xmac, &sec_inc);
- temp = div_u64(1000000000ULL, sec_inc);
+ temp = div_u64(1000000000ULL, (sec_inc > 0) ? sec_inc : 1);
/* Store sub second increment for later use */
priv->sub_second_inc = sec_inc;
--
2.25.1
Powered by blists - more mailing lists