path: root/kernel
diff options
authorJonathan Lemon <>2019-09-24 09:25:21 -0700
committerDaniel Borkmann <>2019-09-25 22:14:16 +0200
commitfcd30ae0665c778e283f73c1c885c7fd26d12ef2 (patch)
tree2adc59ffd81cc960357f76910e7df660c9bb30f2 /kernel
parent8a03222f508bf09e03cf38f6bd77b34b450c1d60 (diff)
bpf/xskmap: Return ERR_PTR for failure case instead of NULL.
When kzalloc() failed, NULL was returned to the caller, which tested the pointer with IS_ERR(), which didn't match, so the pointer was used later, resulting in a NULL dereference. Return ERR_PTR(-ENOMEM) instead of NULL. Reported-by: Fixes: 0402acd683c6 ("xsk: remove AF_XDP socket from map when the socket is released") Signed-off-by: Jonathan Lemon <> Acked-by: Björn Töpel <> Signed-off-by: Daniel Borkmann <>
Diffstat (limited to 'kernel')
1 files changed, 1 insertions, 1 deletions
diff --git a/kernel/bpf/xskmap.c b/kernel/bpf/xskmap.c
index 942c662e2eed..82a1ffe15dfa 100644
--- a/kernel/bpf/xskmap.c
+++ b/kernel/bpf/xskmap.c
@@ -37,7 +37,7 @@ static struct xsk_map_node *xsk_map_node_alloc(struct xsk_map *map,
node = kzalloc(sizeof(*node), GFP_ATOMIC | __GFP_NOWARN);
if (!node)
- return NULL;
+ return ERR_PTR(-ENOMEM);
err = xsk_map_inc(map);
if (err) {