From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 EB72D28853A; Wed, 4 Feb 2026 15:18:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770218293; cv=none; b=h5iVV2MmIms/4wlgqnPqIRLt+L7o2u56CMVL78GzEf9DP0/a0OJP7Q/cB8YXv5hp/e9Dt35/PpGUmFzUwSKlS1eRti+us50/P/07Ac5Rk/lIvMzCo5HbfGBUEtsLcw2fTH8xn/ZJR+8Ho+C4daEroRtJk0YSOZ/9U64lBBEXMxM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770218293; c=relaxed/simple; bh=xj3UgVhfs5P5wp6YFfk7tkG2otdHxzyWVXE6KHb/AXE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=BWeCGORWzd5MVzkBS2tv0MTl5ubA76cHfyJ2awQcO+XJOTTPQy/IjIwo7+f6+zWEmfchZVoqGJdFmEo3jT1OAx7n3c6He5FnP85yCOgFGgc+NCe6Rsmu18EeUXrCGFCjuPTS8E2X+1ZFbfY2daACAbuO3yzVICEwSHg/jgMr6yo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=f2QFVkJL; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="f2QFVkJL" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 450AEC4CEF7; Wed, 4 Feb 2026 15:18:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1770218292; bh=xj3UgVhfs5P5wp6YFfk7tkG2otdHxzyWVXE6KHb/AXE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=f2QFVkJLOYzYmhcvfxE2+NiuXwfRPqU7tGgH6sKbUVRc9456ti+O++6srgmRk4BkF HBTnS1+vnqft/qChWs2Q0bkgu42nhjAW0UfPpEJS773YWOgVqxisD6R4R1toH5tDYW imoAGQUkVyCpSFJaCWIr9uQ8+Ft7bbXPN18fH9ac= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Maxime Chevallier , =?UTF-8?q?Alexis=20Lothor=C3=A9?= , Jakub Kicinski , Rahul Sharma Subject: [PATCH 6.1 267/280] net: stmmac: make sure that ptp_rate is not 0 before configuring EST Date: Wed, 4 Feb 2026 15:40:41 +0100 Message-ID: <20260204143919.307733721@linuxfoundation.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260204143909.614719725@linuxfoundation.org> References: <20260204143909.614719725@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 6.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: Alexis Lothoré [ Upstream commit cbefe2ffa7784525ec5d008ba87c7add19ec631a ] 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é 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 Signed-off-by: Greg Kroah-Hartman --- drivers/net/ethernet/stmicro/stmmac/dwmac5.c | 5 +++++ drivers/net/ethernet/stmicro/stmmac/dwxgmac2_core.c | 5 +++++ 2 files changed, 10 insertions(+) --- 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 *i int i, ret = 0x0; u32 ctrl; + if (!ptp_rate) { + pr_warn("Dwmac5: Invalid PTP rate"); + return -EINVAL; + } + ret |= dwmac5_est_write(ioaddr, BTR_LOW, cfg->btr[0], false); ret |= dwmac5_est_write(ioaddr, BTR_HIGH, cfg->btr[1], false); ret |= dwmac5_est_write(ioaddr, TER, cfg->ter, false); --- 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 _ int i, ret = 0x0; u32 ctrl; + if (!ptp_rate) { + pr_warn("Dwxgmac2: Invalid PTP rate"); + return -EINVAL; + } + ret |= dwxgmac3_est_write(ioaddr, XGMAC_BTR_LOW, cfg->btr[0], false); ret |= dwxgmac3_est_write(ioaddr, XGMAC_BTR_HIGH, cfg->btr[1], false); ret |= dwxgmac3_est_write(ioaddr, XGMAC_TER, cfg->ter, false);