[lvc-project] [PATCH net] net: dsa: sja1105: reject zero pin duration for PTP perout

Aleksandrova Alyona aga at itb.spb.ru
Wed Jun 3 14:02:16 MSK 2026


pin_duration is converted from the user-provided period to SJA1105
clock ticks and is later passed as the cycle_time argument to
future_base_time().

Very small period values may become zero after the conversion,
which can lead to a division by zero in future_base_time().

Reject zero pin_duration values and values that exceed the
supported range.

Found by Linux Verification Center (linuxtesting.org) with SVACE.

Fixes: 747e5eb31d59 ("net: dsa: sja1105: configure the PTP_CLK pin as EXT_TS or PER_OUT")
Signed-off-by: Aleksandrova Alyona <aga ÎÁ itb.spb.ru>
---
 drivers/net/dsa/sja1105/sja1105_ptp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/dsa/sja1105/sja1105_ptp.c b/drivers/net/dsa/sja1105/sja1105_ptp.c
index a7d41e781398..107cf8097d32 100644
--- a/drivers/net/dsa/sja1105/sja1105_ptp.c
+++ b/drivers/net/dsa/sja1105/sja1105_ptp.c
@@ -756,7 +756,7 @@ static int sja1105_per_out_enable(struct sja1105_private *priv,
 		 * at periods larger than around 68.7 seconds.
 		 */
 		pin_duration = ns_to_sja1105_ticks(pin_duration / 2);
-		if (pin_duration > U32_MAX) {
+		if (!pin_duration || pin_duration > U32_MAX) {
 			rc = -ERANGE;
 			goto out;
 		}
-- 
2.26.2




More information about the lvc-project mailing list