|
@@ -75,8 +75,8 @@ static u64 dev_map_bitmap_size(const union bpf_attr *attr)
|
|
|
static struct bpf_map *dev_map_alloc(union bpf_attr *attr)
|
|
|
{
|
|
|
struct bpf_dtab *dtab;
|
|
|
+ int err = -EINVAL;
|
|
|
u64 cost;
|
|
|
- int err;
|
|
|
|
|
|
/* check sanity of attributes */
|
|
|
if (attr->max_entries == 0 || attr->key_size != 4 ||
|
|
@@ -108,6 +108,8 @@ static struct bpf_map *dev_map_alloc(union bpf_attr *attr)
|
|
|
if (err)
|
|
|
goto free_dtab;
|
|
|
|
|
|
+ err = -ENOMEM;
|
|
|
+
|
|
|
/* A per cpu bitfield with a bit per possible net device */
|
|
|
dtab->flush_needed = __alloc_percpu(dev_map_bitmap_size(attr),
|
|
|
__alignof__(unsigned long));
|
|
@@ -128,7 +130,7 @@ static struct bpf_map *dev_map_alloc(union bpf_attr *attr)
|
|
|
free_dtab:
|
|
|
free_percpu(dtab->flush_needed);
|
|
|
kfree(dtab);
|
|
|
- return ERR_PTR(-ENOMEM);
|
|
|
+ return ERR_PTR(err);
|
|
|
}
|
|
|
|
|
|
static void dev_map_free(struct bpf_map *map)
|