net: stmmac: make sure that ptp_rate is not 0 before configuring EST
Subsystems (4)
PATCH 1/1 net: stmmac: make sure that ptp_rate is not 0 before configuring EST
From: Alexis Lothoré <[email protected]>
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.
[ The context change is due to the commit c3f3b97238f6 ("net: stmmac: Refactor EST implementation") which is irrelevant to the logic of this patch. ]
--- drivers/net/ethernet/stmicro/stmmac/dwmac5.c | 5 +++++ drivers/net/ethernet/stmicro/stmmac/dwxgmac2_core.c | 5 +++++ 2 files changed, 10 insertions(+)
drivers/net/ethernet/stmicro/stmmac/dwmac5.c +5 -0
@@ -597,6 +597,11 @@ int dwmac5_est_configure(void __iomem *ioaddr, struct stmmac_est *cfg,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);
drivers/net/ethernet/stmicro/stmmac/dwxgmac2_core.c +5 -0
@@ -1537,6 +1537,11 @@ static int dwxgmac3_est_configure(void __iomem *ioaddr, struct stmmac_est *cfg,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);
Signature · 1 line
2.34.1
Greg KH
maintainerQuoted 14 lines · Rahul Sharma
From: Alexis Lothoré <[email protected]>
If the
ptp_raterecorded 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 <[email protected]>Signed-off-by Alexis Lothoré <[email protected]>Fixes 8572aec3d0dc ("net: stmmac: Add basic EST support for XGMAC")Signed-off-by Jakub Kicinski <[email protected]>
Quoted 8 lines
[ The context change is due to the commit
c3f3b97238f6("net: stmmac: Refactor EST implementation") which is irrelevant to the logic of this patch. ]Signed-off-by Rahul Sharma <[email protected]>--- drivers/net/ethernet/stmicro/stmmac/dwmac5.c | 5 +++++ drivers/net/ethernet/stmicro/stmmac/dwxgmac2_core.c | 5 +++++ 2 files changed, 10 insertions(+)
What is the git id of this commit in Linus's tree?
thanks,
greg k-h