diff options
author | Daniel Vetter <daniel.vetter@ffwll.ch> | 2017-02-26 15:34:42 -0500 |
---|---|---|
committer | Daniel Vetter <daniel.vetter@ffwll.ch> | 2017-02-26 15:34:42 -0500 |
commit | 8e22e1b3499a446df48c2b26667ca36c55bf864c (patch) | |
tree | 5329f98b3eb3c95a9dcbab0fa4f9b6e62f0e788d /kernel/bpf/arraymap.c | |
parent | 00d3c14f14d51babd8aeafd5fa734ccf04f5ca3d (diff) | |
parent | 64a577196d66b44e37384bc5c4d78c61f59d5b2a (diff) |
Merge airlied/drm-next into drm-misc-next
Backmerge the main pull request to sync up with all the newly landed
drivers. Otherwise we'll have chaos even before 4.12 started in
earnest.
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Diffstat (limited to 'kernel/bpf/arraymap.c')
-rw-r--r-- | kernel/bpf/arraymap.c | 18 |
1 files changed, 7 insertions, 11 deletions
diff --git a/kernel/bpf/arraymap.c b/kernel/bpf/arraymap.c index 229a5d5df977..3d55d95dcf49 100644 --- a/kernel/bpf/arraymap.c +++ b/kernel/bpf/arraymap.c | |||
@@ -11,7 +11,6 @@ | |||
11 | */ | 11 | */ |
12 | #include <linux/bpf.h> | 12 | #include <linux/bpf.h> |
13 | #include <linux/err.h> | 13 | #include <linux/err.h> |
14 | #include <linux/vmalloc.h> | ||
15 | #include <linux/slab.h> | 14 | #include <linux/slab.h> |
16 | #include <linux/mm.h> | 15 | #include <linux/mm.h> |
17 | #include <linux/filter.h> | 16 | #include <linux/filter.h> |
@@ -74,14 +73,10 @@ static struct bpf_map *array_map_alloc(union bpf_attr *attr) | |||
74 | if (array_size >= U32_MAX - PAGE_SIZE) | 73 | if (array_size >= U32_MAX - PAGE_SIZE) |
75 | return ERR_PTR(-ENOMEM); | 74 | return ERR_PTR(-ENOMEM); |
76 | 75 | ||
77 | |||
78 | /* allocate all map elements and zero-initialize them */ | 76 | /* allocate all map elements and zero-initialize them */ |
79 | array = kzalloc(array_size, GFP_USER | __GFP_NOWARN); | 77 | array = bpf_map_area_alloc(array_size); |
80 | if (!array) { | 78 | if (!array) |
81 | array = vzalloc(array_size); | 79 | return ERR_PTR(-ENOMEM); |
82 | if (!array) | ||
83 | return ERR_PTR(-ENOMEM); | ||
84 | } | ||
85 | 80 | ||
86 | /* copy mandatory map attributes */ | 81 | /* copy mandatory map attributes */ |
87 | array->map.map_type = attr->map_type; | 82 | array->map.map_type = attr->map_type; |
@@ -97,7 +92,7 @@ static struct bpf_map *array_map_alloc(union bpf_attr *attr) | |||
97 | 92 | ||
98 | if (array_size >= U32_MAX - PAGE_SIZE || | 93 | if (array_size >= U32_MAX - PAGE_SIZE || |
99 | elem_size > PCPU_MIN_UNIT_SIZE || bpf_array_alloc_percpu(array)) { | 94 | elem_size > PCPU_MIN_UNIT_SIZE || bpf_array_alloc_percpu(array)) { |
100 | kvfree(array); | 95 | bpf_map_area_free(array); |
101 | return ERR_PTR(-ENOMEM); | 96 | return ERR_PTR(-ENOMEM); |
102 | } | 97 | } |
103 | out: | 98 | out: |
@@ -262,7 +257,7 @@ static void array_map_free(struct bpf_map *map) | |||
262 | if (array->map.map_type == BPF_MAP_TYPE_PERCPU_ARRAY) | 257 | if (array->map.map_type == BPF_MAP_TYPE_PERCPU_ARRAY) |
263 | bpf_array_free_percpu(array); | 258 | bpf_array_free_percpu(array); |
264 | 259 | ||
265 | kvfree(array); | 260 | bpf_map_area_free(array); |
266 | } | 261 | } |
267 | 262 | ||
268 | static const struct bpf_map_ops array_ops = { | 263 | static const struct bpf_map_ops array_ops = { |
@@ -319,7 +314,8 @@ static void fd_array_map_free(struct bpf_map *map) | |||
319 | /* make sure it's empty */ | 314 | /* make sure it's empty */ |
320 | for (i = 0; i < array->map.max_entries; i++) | 315 | for (i = 0; i < array->map.max_entries; i++) |
321 | BUG_ON(array->ptrs[i] != NULL); | 316 | BUG_ON(array->ptrs[i] != NULL); |
322 | kvfree(array); | 317 | |
318 | bpf_map_area_free(array); | ||
323 | } | 319 | } |
324 | 320 | ||
325 | static void *fd_array_map_lookup_elem(struct bpf_map *map, void *key) | 321 | static void *fd_array_map_lookup_elem(struct bpf_map *map, void *key) |