Skip to content

Commit

Permalink
libxdp: Fix xdp prog memory leak in xsk_setup_xdp_prog
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
ricmli authored and tohojo committed Nov 21, 2023
1 parent c9913f9 commit cae9c91
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions lib/libxdp/xsk.c
Original file line number Diff line number Diff line change
Expand Up @@ -978,6 +978,7 @@ static struct xsk_ctx *xsk_create_ctx(struct xsk_socket *xsk,

static void xsk_destroy_xsk_struct(struct xsk_socket *xsk)
{
xdp_program__close(xsk->ctx->xdp_prog);
free(xsk->ctx);
free(xsk);
}
Expand Down

0 comments on commit cae9c91

Please sign in to comment.