Skip to content

Commit e0ae713

Browse files
Sebastian Andrzej Siewiorkuba-moo
authored andcommitted
xdp: xdp_mem_allocator can be NULL in trace_mem_connect().
Since the commit mentioned below __xdp_reg_mem_model() can return a NULL pointer. This pointer is dereferenced in trace_mem_connect() which leads to segfault. The trace points (mem_connect + mem_disconnect) were put in place to pair connect/disconnect using the IDs. The ID is only assigned if __xdp_reg_mem_model() does not return NULL. That connect trace point is of no use if there is no ID. Skip that connect trace point if xdp_alloc is NULL. [ Toke Høiland-Jørgensen delivered the reasoning for skipping the trace point ] Fixes: 4a48ef7 ("xdp: Allow registering memory model without rxq reference") Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> Acked-by: Toke Høiland-Jørgensen <toke@redhat.com> Link: https://lore.kernel.org/r/YikmmXsffE+QajTB@linutronix.de Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1 parent 5cb1ebd commit e0ae713

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

net/core/xdp.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,8 @@ int xdp_rxq_info_reg_mem_model(struct xdp_rxq_info *xdp_rxq,
357357
if (IS_ERR(xdp_alloc))
358358
return PTR_ERR(xdp_alloc);
359359

360-
trace_mem_connect(xdp_alloc, xdp_rxq);
360+
if (trace_mem_connect_enabled() && xdp_alloc)
361+
trace_mem_connect(xdp_alloc, xdp_rxq);
361362
return 0;
362363
}
363364

0 commit comments

Comments
 (0)