summaryrefslogtreecommitdiffstats
path: root/kernel/bpf/stackmap.c
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2021-02-10 22:30:12 +0100
committerDavid S. Miller <davem@davemloft.net>2021-02-10 22:30:12 +0100
commitdc9d87581d464e7b7d38853d6904b70b6c920d99 (patch)
tree15aa27fefb867814899c0a0c194adf327675ba10 /kernel/bpf/stackmap.c
parentMerge branch '40GbE' of git://git.kernel.org/pub/scm/linux/kernel/git/tnguy/n... (diff)
parentMerge tag 'pm-5.11-rc8' of git://git.kernel.org/pub/scm/linux/kernel/git/rafa... (diff)
downloadlinux-dc9d87581d464e7b7d38853d6904b70b6c920d99.tar.xz
linux-dc9d87581d464e7b7d38853d6904b70b6c920d99.zip
Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net
Diffstat (limited to 'kernel/bpf/stackmap.c')
-rw-r--r--kernel/bpf/stackmap.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/kernel/bpf/stackmap.c b/kernel/bpf/stackmap.c
index cabaf7db8efc..be35bfb7fb13 100644
--- a/kernel/bpf/stackmap.c
+++ b/kernel/bpf/stackmap.c
@@ -114,6 +114,8 @@ static struct bpf_map *stack_map_alloc(union bpf_attr *attr)
/* hash table size must be power of 2 */
n_buckets = roundup_pow_of_two(attr->max_entries);
+ if (!n_buckets)
+ return ERR_PTR(-E2BIG);
cost = n_buckets * sizeof(struct stack_map_bucket *) + sizeof(*smap);
cost += n_buckets * (value_size + sizeof(struct stack_map_bucket));