Skip to content

Commit

Permalink
xsk: recycle buffer in case Rx queue was full
Browse files Browse the repository at this point in the history
[ Upstream commit 2690098 ]

Add missing xsk_buff_free() call when __xsk_rcv_zc() failed to produce
descriptor to XSK Rx queue.

Fixes: 24ea501 ("xsk: support mbuf on ZC RX")
Acked-by: Magnus Karlsson <[email protected]>
Signed-off-by: Maciej Fijalkowski <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Alexei Starovoitov <[email protected]>
Signed-off-by: Sasha Levin <[email protected]>
  • Loading branch information
mfijalko authored and gregkh committed Feb 1, 2024
1 parent 1b62822 commit 7b4d93d
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions net/xdp/xsk.c
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,10 @@ static int xsk_rcv_zc(struct xdp_sock *xs, struct xdp_buff *xdp, u32 len)
contd = XDP_PKT_CONTD;

err = __xsk_rcv_zc(xs, xskb, len, contd);
if (err || likely(!frags))
goto out;
if (err)
goto err;
if (likely(!frags))
return 0;

xskb_list = &xskb->pool->xskb_list;
list_for_each_entry_safe(pos, tmp, xskb_list, xskb_list_node) {
Expand All @@ -177,11 +179,13 @@ static int xsk_rcv_zc(struct xdp_sock *xs, struct xdp_buff *xdp, u32 len)
len = pos->xdp.data_end - pos->xdp.data;
err = __xsk_rcv_zc(xs, pos, len, contd);
if (err)
return err;
goto err;
list_del(&pos->xskb_list_node);
}

out:
return 0;
err:
xsk_buff_free(xdp);
return err;
}

Expand Down

0 comments on commit 7b4d93d

Please sign in to comment.