Skip to content

Commit 2764ab5

Browse files
JasonXingkuba-moo
authored andcommitted
stmmac: xsk: fix negative overflow of budget in zerocopy mode
A negative overflow can happen when the budget number of descs are consumed. as long as the budget is decreased to zero, it will again go into while (budget-- > 0) statement and get decreased by one, so the overflow issue can happen. It will lead to returning true whereas the expected value should be false. In this case where all the budget is used up, it means zc function should return false to let the poll run again because normally we might have more data to process. Without this patch, zc function would return true instead. Fixes: 132c32e ("net: stmmac: Add TX via XDP zero-copy socket") Signed-off-by: Jason Xing <[email protected]> Reviewed-by: Aleksandr Loktionov <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent eccf7a3 commit 2764ab5

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2596,7 +2596,7 @@ static bool stmmac_xdp_xmit_zc(struct stmmac_priv *priv, u32 queue, u32 budget)
25962596

25972597
budget = min(budget, stmmac_tx_avail(priv, queue));
25982598

2599-
while (budget-- > 0) {
2599+
for (; budget > 0; budget--) {
26002600
struct stmmac_metadata_request meta_req;
26012601
struct xsk_tx_metadata *meta = NULL;
26022602
dma_addr_t dma_addr;

0 commit comments

Comments
 (0)