Skip to content

Commit 675faf5

Browse files
KhaiWenTanPaolo Abeni
authored andcommitted
net: stmmac: Fix zero-division error when disabling tc cbs
The commit b8c4336 ("net: stmmac: No need to calculate speed divider when offload is disabled") allows the "port_transmit_rate_kbps" to be set to a value of 0, which is then passed to the "div_s64" function when tc-cbs is disabled. This leads to a zero-division error. When tc-cbs is disabled, the idleslope, sendslope, and credit values the credit values are not required to be configured. Therefore, adding a return statement after setting the txQ mode to DCB when tc-cbs is disabled would prevent a zero-division error. Fixes: b8c4336 ("net: stmmac: No need to calculate speed divider when offload is disabled") Cc: <[email protected]> Co-developed-by: Choong Yong Liang <[email protected]> Signed-off-by: Choong Yong Liang <[email protected]> Signed-off-by: KhaiWenTan <[email protected]> Reviewed-by: Simon Horman <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Paolo Abeni <[email protected]>
1 parent ced8e8b commit 675faf5

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -386,6 +386,7 @@ static int tc_setup_cbs(struct stmmac_priv *priv,
386386
return ret;
387387

388388
priv->plat->tx_queues_cfg[queue].mode_to_use = MTL_QUEUE_DCB;
389+
return 0;
389390
}
390391

391392
/* Final adjustments for HW */

0 commit comments

Comments
 (0)