Commit f78331f7 authored by Magnus Karlsson's avatar Magnus Karlsson Committed by Daniel Borkmann

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: 2f6324a3 ("libbpf: Support shared umems between queues and devices")
Reported-by: default avatarAndrii Nakryiko <andrii.nakryiko@gmail.com>
Signed-off-by: default avatarMagnus Karlsson <magnus.karlsson@intel.com>
Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
Acked-by: default avatarAndrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/bpf/1604396490-12129-2-git-send-email-magnus.karlsson@gmail.com
parent 7a078d2d
...@@ -891,13 +891,14 @@ int xsk_umem__delete(struct xsk_umem *umem) ...@@ -891,13 +891,14 @@ int xsk_umem__delete(struct xsk_umem *umem)
void xsk_socket__delete(struct xsk_socket *xsk) void xsk_socket__delete(struct xsk_socket *xsk)
{ {
size_t desc_sz = sizeof(struct xdp_desc); size_t desc_sz = sizeof(struct xdp_desc);
struct xsk_ctx *ctx = xsk->ctx;
struct xdp_mmap_offsets off; struct xdp_mmap_offsets off;
struct xsk_ctx *ctx;
int err; int err;
if (!xsk) if (!xsk)
return; return;
ctx = xsk->ctx;
if (ctx->prog_fd != -1) { if (ctx->prog_fd != -1) {
xsk_delete_bpf_maps(xsk); xsk_delete_bpf_maps(xsk);
close(ctx->prog_fd); close(ctx->prog_fd);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment