Skip to content

Commit afd0be7

Browse files
cloftusborkmann
authored andcommitted
libbpf: Fix potential NULL pointer dereference
Wait until after the UMEM is checked for null to dereference it. Fixes: 43f1bc1 ("libbpf: Restore umem state after socket create failure") Signed-off-by: Ciara Loftus <[email protected]> Signed-off-by: Daniel Borkmann <[email protected]> Link: https://lore.kernel.org/bpf/[email protected]
1 parent 1ffbc7e commit afd0be7

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

tools/lib/bpf/xsk.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -852,18 +852,19 @@ int xsk_socket__create_shared(struct xsk_socket **xsk_ptr,
852852
struct xsk_ring_cons *comp,
853853
const struct xsk_socket_config *usr_config)
854854
{
855+
bool unmap, rx_setup_done = false, tx_setup_done = false;
855856
void *rx_map = NULL, *tx_map = NULL;
856857
struct sockaddr_xdp sxdp = {};
857858
struct xdp_mmap_offsets off;
858859
struct xsk_socket *xsk;
859860
struct xsk_ctx *ctx;
860861
int err, ifindex;
861-
bool unmap = umem->fill_save != fill;
862-
bool rx_setup_done = false, tx_setup_done = false;
863862

864863
if (!umem || !xsk_ptr || !(rx || tx))
865864
return -EFAULT;
866865

866+
unmap = umem->fill_save != fill;
867+
867868
xsk = calloc(1, sizeof(*xsk));
868869
if (!xsk)
869870
return -ENOMEM;

0 commit comments

Comments
 (0)