From nobody Sun Feb 8 09:22:30 2026 Received: from m16.mail.163.com (m16.mail.163.com [117.135.210.5]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0A9041EB9E1; Fri, 30 Jan 2026 02:38:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=117.135.210.5 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769740685; cv=none; b=UjVHErQZ0c4wuOYLFzJ3+ne9zhR0adxwrVU5I+z1LiqQLnZb7Hapv0nq8QqlyekcRybhwzjsixJ2Dzp72ly6B6cTrXNJDgXpv/WSngVOry+o5WipcWweuBAJfqgdA+oEHcE/TeyM05MRT9eNr/ohi+5jdIx669zIe7rhhzJfSBk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769740685; c=relaxed/simple; bh=XoCGmtKIL2kudFYfX8yG6xddZrcl2tEnErJHjcjGy2k=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version:Content-Type; b=C9EmcXUX4Ri6Bvizh+dl0V/FSVYe8/orq5lglEPv5I5WAJSIpFW3JzWhbzlQRouPPCVDjW2a1bo64iQ3sYrWBR+lDKoigpAaPFYRxeb+ZhXealswKnv8/KdF39fUeTyAzFy/fF/uFRYysMnS+s/C+0CNdm7Ayg2m4ubj2eNlb68= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=163.com; spf=pass smtp.mailfrom=163.com; dkim=pass (1024-bit key) header.d=163.com header.i=@163.com header.b=AGs4ee/A; arc=none smtp.client-ip=117.135.210.5 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=163.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=163.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=163.com header.i=@163.com header.b="AGs4ee/A" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:To:Subject:Date:Message-Id:MIME-Version: Content-Type; bh=ak+stKbQO+SG0zj6nGU7d67tPLLkh6z5jY0vfqhLTWc=; b=AGs4ee/AUzcOv1DEOrrAY4rxyPiCJU7nTpqZzg4rcs1/OEiGV0cts+6ECKQkHV LndphiGdeBAwDN22qvR1lzeXCr4TVqDIurG+186mps/3jwGYrHs95RIrvuYiRI9N JLCjG51kSmvsmuljNEW4wQA5UZcYYAEqDQmwxUpkyEx/M= Received: from pek-lpg-core6.wrs.com (unknown []) by gzga-smtp-mtada-g0-4 (Coremail) with SMTP id _____wD3sf9gGXxp4GANIw--.640S2; Fri, 30 Jan 2026 10:37:22 +0800 (CST) From: Rahul Sharma To: gregkh@linuxfoundation.org, stable@vger.kernel.org Cc: linux-kernel@vger.kernel.org, =?UTF-8?q?Alexis=20Lothor=C3=A9?= , Maxime Chevallier , Jakub Kicinski , Rahul Sharma Subject: [PATCH 6.1.y] net: stmmac: make sure that ptp_rate is not 0 before configuring EST Date: Fri, 30 Jan 2026 10:37:18 +0800 Message-Id: <20260130023718.3757414-1-black.hawk@163.com> X-Mailer: git-send-email 2.34.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-CM-TRANSID: _____wD3sf9gGXxp4GANIw--.640S2 X-Coremail-Antispam: 1Uf129KBjvJXoWxGr47ArW7Aw4xJr4UKw4xXrb_yoW5Gr1DpF W7AFyFvr97tF1fJ3WkJF4kXF98WayDtrWDWryfKw4fuFWav3yqqF9avFyrtF1Utrs8XFW3 tr4jkr1xCFn8urUanT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x0z_ManUUUUUU= X-CM-SenderInfo: 5eoduy4okd4yi6rwjhhfrp/xtbC3gPXcWl8GWOa9QAA37 From: Alexis Lothor=C3=A9 [ Upstream commit f11cf946c0a92c560a890d68e4775723353599e1 ] 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 Signed-off-by: Alexis Lothor=C3=A9 Fixes: 8572aec3d0dc ("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 [ The context change is due to the commit c3f3b97238f6 ("net: stmmac: Refactor EST implementation") and the proper adoption is done. ] Signed-off-by: Rahul Sharma --- drivers/net/ethernet/stmicro/stmmac/dwmac5.c | 5 +++++ drivers/net/ethernet/stmicro/stmmac/dwxgmac2_core.c | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac5.c b/drivers/net/eth= ernet/stmicro/stmmac/dwmac5.c index 8fd167501fa0..0afd4644a985 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac5.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac5.c @@ -597,6 +597,11 @@ int dwmac5_est_configure(void __iomem *ioaddr, struct = stmmac_est *cfg, int i, ret =3D 0x0; u32 ctrl; =20 + if (!ptp_rate) { + pr_warn("Dwmac5: Invalid PTP rate"); + return -EINVAL; + } + ret |=3D dwmac5_est_write(ioaddr, BTR_LOW, cfg->btr[0], false); ret |=3D dwmac5_est_write(ioaddr, BTR_HIGH, cfg->btr[1], false); ret |=3D dwmac5_est_write(ioaddr, TER, cfg->ter, false); diff --git a/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_core.c b/drivers/= net/ethernet/stmicro/stmmac/dwxgmac2_core.c index d0e2748a0ed2..b73c8dcfacee 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_core.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_core.c @@ -1497,6 +1497,11 @@ static int dwxgmac3_est_configure(void __iomem *ioad= dr, struct stmmac_est *cfg, int i, ret =3D 0x0; u32 ctrl; =20 + if (!ptp_rate) { + pr_warn("Dwxgmac2: Invalid PTP rate"); + return -EINVAL; + } + ret |=3D dwxgmac3_est_write(ioaddr, XGMAC_BTR_LOW, cfg->btr[0], false); ret |=3D dwxgmac3_est_write(ioaddr, XGMAC_BTR_HIGH, cfg->btr[1], false); ret |=3D dwxgmac3_est_write(ioaddr, XGMAC_TER, cfg->ter, false); --=20 2.34.1