Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f740c34e authored by Dan Carpenter's avatar Dan Carpenter Committed by David S. Miller
Browse files

bpf: fix oops on allocation failure



"err" is set to zero if bpf_map_area_alloc() fails so it means we return
ERR_PTR(0) which is NULL.  The caller, find_and_alloc_map(), is not
expecting NULL returns and will oops.

Fixes: 174a79ff ("bpf: sockmap with sk redirect support")
Signed-off-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
Acked-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
Acked-by: default avatarAlexei Starovoitov <ast@kernel.org>
Acked-by: default avatarJohn Fastabend <john.fastabend@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent a8e3bb34
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -523,6 +523,7 @@ static struct bpf_map *sock_map_alloc(union bpf_attr *attr)
	if (err)
		goto free_stab;

	err = -ENOMEM;
	stab->sock_map = bpf_map_area_alloc(stab->map.max_entries *
					    sizeof(struct sock *),
					    stab->map.numa_node);