aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/bpf/syscall.c
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/bpf/syscall.c')
-rw-r--r--kernel/bpf/syscall.c17
1 files changed, 13 insertions, 4 deletions
diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c
index 2bac0dc8baba..c0ac03a04880 100644
--- a/kernel/bpf/syscall.c
+++ b/kernel/bpf/syscall.c
@@ -96,16 +96,25 @@ static int check_uarg_tail_zero(void __user *uaddr,
96 96
97static struct bpf_map *find_and_alloc_map(union bpf_attr *attr) 97static struct bpf_map *find_and_alloc_map(union bpf_attr *attr)
98{ 98{
99 const struct bpf_map_ops *ops;
99 struct bpf_map *map; 100 struct bpf_map *map;
101 int err;
100 102
101 if (attr->map_type >= ARRAY_SIZE(bpf_map_types) || 103 if (attr->map_type >= ARRAY_SIZE(bpf_map_types))
102 !bpf_map_types[attr->map_type]) 104 return ERR_PTR(-EINVAL);
105 ops = bpf_map_types[attr->map_type];
106 if (!ops)
103 return ERR_PTR(-EINVAL); 107 return ERR_PTR(-EINVAL);
104 108
105 map = bpf_map_types[attr->map_type]->map_alloc(attr); 109 if (ops->map_alloc_check) {
110 err = ops->map_alloc_check(attr);
111 if (err)
112 return ERR_PTR(err);
113 }
114 map = ops->map_alloc(attr);
106 if (IS_ERR(map)) 115 if (IS_ERR(map))
107 return map; 116 return map;
108 map->ops = bpf_map_types[attr->map_type]; 117 map->ops = ops;
109 map->map_type = attr->map_type; 118 map->map_type = attr->map_type;
110 return map; 119 return map;
111} 120}