]> git.proxmox.com Git - mirror_ubuntu-eoan-kernel.git/blobdiff - kernel/bpf/xskmap.c
bpf: remove redundant assignment to err
[mirror_ubuntu-eoan-kernel.git] / kernel / bpf / xskmap.c
index f816ee1a0fa0bc6f9e19a7ab9fb7244d967c21d3..413d75f4fc726816a07bbd668c5420ab73b77d79 100644 (file)
@@ -17,8 +17,8 @@ struct xsk_map {
 
 static struct bpf_map *xsk_map_alloc(union bpf_attr *attr)
 {
-       int cpu, err = -EINVAL;
        struct xsk_map *m;
+       int cpu, err;
        u64 cost;
 
        if (!capable(CAP_NET_ADMIN))
@@ -37,13 +37,9 @@ static struct bpf_map *xsk_map_alloc(union bpf_attr *attr)
 
        cost = (u64)m->map.max_entries * sizeof(struct xdp_sock *);
        cost += sizeof(struct list_head) * num_possible_cpus();
-       if (cost >= U32_MAX - PAGE_SIZE)
-               goto free_m;
-
-       m->map.memory.pages = round_up(cost, PAGE_SIZE) >> PAGE_SHIFT;
 
        /* Notice returns -EPERM on if map size is larger than memlock limit */
-       err = bpf_map_precharge_memlock(m->map.memory.pages);
+       err = bpf_map_charge_init(&m->map.memory, cost);
        if (err)
                goto free_m;
 
@@ -51,7 +47,7 @@ static struct bpf_map *xsk_map_alloc(union bpf_attr *attr)
 
        m->flush_list = alloc_percpu(struct list_head);
        if (!m->flush_list)
-               goto free_m;
+               goto free_charge;
 
        for_each_possible_cpu(cpu)
                INIT_LIST_HEAD(per_cpu_ptr(m->flush_list, cpu));
@@ -65,6 +61,8 @@ static struct bpf_map *xsk_map_alloc(union bpf_attr *attr)
 
 free_percpu:
        free_percpu(m->flush_list);
+free_charge:
+       bpf_map_charge_finish(&m->map.memory);
 free_m:
        kfree(m);
        return ERR_PTR(err);