gve: fix XSK buffer leak on error descriptor

When the error bit is set in the RX completion descriptor, the buf_state
and its attached buffer should be freed. In the case of AF_XDP ZC, the
XSK buffer was not freed, leading to a leak.

This issue was caught by LLM.

Fixes: c1fffc5d66 ("gve: implement DQO RX datapath and control path for AF_XDP zero-copy")
Cc: stable@vger.kernel.org
Reviewed-by: Jordan Rhee <jordanrhee@google.com>
Reviewed-by: Tim Hostetler <thostet@google.com>
Signed-off-by: Joshua Washington <joshwash@google.com>
Link: https://patch.msgid.link/20260930214735.3288780-3-joshwash@google.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
Joshua Washington 2026-09-30 14:47:34 -07:00 committed by Jakub Kicinski
parent 73670ddb91
commit 9fed6a8ab8

View File

@ -842,7 +842,12 @@ static int gve_rx_dqo(struct napi_struct *napi, struct gve_rx_ring *rx,
}
if (unlikely(compl_desc->rx_error)) {
gve_free_buffer(rx, buf_state);
if (buf_state->xsk_buff) {
xsk_buff_free(buf_state->xsk_buff);
gve_free_buf_state(rx, buf_state);
} else {
gve_free_buffer(rx, buf_state);
}
return -EINVAL;
}