Skip to content

Commit f78331f

Browse files
magnus-karlssonborkmann
authored andcommitted
libbpf: Fix null dereference in xsk_socket__delete
Fix a possible null pointer dereference in xsk_socket__delete that will occur if a null pointer is fed into the function. Fixes: 2f6324a ("libbpf: Support shared umems between queues and devices") Reported-by: Andrii Nakryiko <[email protected]> Signed-off-by: Magnus Karlsson <[email protected]> Signed-off-by: Daniel Borkmann <[email protected]> Acked-by: Andrii Nakryiko <[email protected]> Link: https://lore.kernel.org/bpf/[email protected]
1 parent 7a078d2 commit f78331f

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

tools/lib/bpf/xsk.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -891,13 +891,14 @@ int xsk_umem__delete(struct xsk_umem *umem)
891891
void xsk_socket__delete(struct xsk_socket *xsk)
892892
{
893893
size_t desc_sz = sizeof(struct xdp_desc);
894-
struct xsk_ctx *ctx = xsk->ctx;
895894
struct xdp_mmap_offsets off;
895+
struct xsk_ctx *ctx;
896896
int err;
897897

898898
if (!xsk)
899899
return;
900900

901+
ctx = xsk->ctx;
901902
if (ctx->prog_fd != -1) {
902903
xsk_delete_bpf_maps(xsk);
903904
close(ctx->prog_fd);

0 commit comments

Comments
 (0)