Skip to content

Commit cae9c91

Browse files
ricmlitohojo
authored andcommitted
libxdp: Fix xdp prog memory leak in xsk_setup_xdp_prog
In the xsk_setup_xdp_prog function, the xsk structure temporarily takes ownership of an xdp_prog and stores it in ctx->xdp_prog. However, the allocated memory is not freed in xsk_destroy_xsk_struct, leading to a memory leak. This commit addresses the issue by adding a call to xdp_program_close to properly release the allocated xdp_prog memory. Signed-off-by: Ric Li <[email protected]>
1 parent c9913f9 commit cae9c91

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

lib/libxdp/xsk.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -978,6 +978,7 @@ static struct xsk_ctx *xsk_create_ctx(struct xsk_socket *xsk,
978978

979979
static void xsk_destroy_xsk_struct(struct xsk_socket *xsk)
980980
{
981+
xdp_program__close(xsk->ctx->xdp_prog);
981982
free(xsk->ctx);
982983
free(xsk);
983984
}

0 commit comments

Comments
 (0)