Merge tag 'tif-task_work.arch-2020-12-14' of git://git.kernel.dk/linux-block
[linux-2.6-microblaze.git] / kernel / bpf / bpf_struct_ops.c
index 4c3b543..1a666a9 100644 (file)
@@ -548,12 +548,10 @@ static int bpf_struct_ops_map_alloc_check(union bpf_attr *attr)
 static struct bpf_map *bpf_struct_ops_map_alloc(union bpf_attr *attr)
 {
        const struct bpf_struct_ops *st_ops;
-       size_t map_total_size, st_map_size;
+       size_t st_map_size;
        struct bpf_struct_ops_map *st_map;
        const struct btf_type *t, *vt;
-       struct bpf_map_memory mem;
        struct bpf_map *map;
-       int err;
 
        if (!bpf_capable())
                return ERR_PTR(-EPERM);
@@ -573,20 +571,11 @@ static struct bpf_map *bpf_struct_ops_map_alloc(union bpf_attr *attr)
                 * struct bpf_struct_ops_tcp_congestions_ops
                 */
                (vt->size - sizeof(struct bpf_struct_ops_value));
-       map_total_size = st_map_size +
-               /* uvalue */
-               sizeof(vt->size) +
-               /* struct bpf_progs **progs */
-                btf_type_vlen(t) * sizeof(struct bpf_prog *);
-       err = bpf_map_charge_init(&mem, map_total_size);
-       if (err < 0)
-               return ERR_PTR(err);
 
        st_map = bpf_map_area_alloc(st_map_size, NUMA_NO_NODE);
-       if (!st_map) {
-               bpf_map_charge_finish(&mem);
+       if (!st_map)
                return ERR_PTR(-ENOMEM);
-       }
+
        st_map->st_ops = st_ops;
        map = &st_map->map;
 
@@ -597,14 +586,12 @@ static struct bpf_map *bpf_struct_ops_map_alloc(union bpf_attr *attr)
        st_map->image = bpf_jit_alloc_exec(PAGE_SIZE);
        if (!st_map->uvalue || !st_map->progs || !st_map->image) {
                bpf_struct_ops_map_free(map);
-               bpf_map_charge_finish(&mem);
                return ERR_PTR(-ENOMEM);
        }
 
        mutex_init(&st_map->lock);
        set_vm_flush_reset_perms(st_map->image);
        bpf_map_init_from_attr(map, attr);
-       bpf_map_charge_move(&map->memory, &mem);
 
        return map;
 }