[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20220902023003.47124-9-laoar.shao@gmail.com>
Date: Fri, 2 Sep 2022 02:29:58 +0000
From: Yafang Shao <laoar.shao@...il.com>
To: ast@...nel.org, daniel@...earbox.net, andrii@...nel.org,
kafai@...com, songliubraving@...com, yhs@...com,
john.fastabend@...il.com, kpsingh@...nel.org, sdf@...gle.com,
haoluo@...gle.com, jolsa@...nel.org, hannes@...xchg.org,
mhocko@...nel.org, roman.gushchin@...ux.dev, shakeelb@...gle.com,
songmuchun@...edance.com, akpm@...ux-foundation.org, tj@...nel.org,
lizefan.x@...edance.com
Cc: cgroups@...r.kernel.org, netdev@...r.kernel.org,
bpf@...r.kernel.org, linux-mm@...ck.org,
Yafang Shao <laoar.shao@...il.com>
Subject: [PATCH bpf-next v3 08/13] bpf: Use bpf_map_kzalloc in arraymap
Allocates memory after map creation, then we can use the generic helper
bpf_map_kzalloc() instead of the open-coded kzalloc().
Signed-off-by: Yafang Shao <laoar.shao@...il.com>
---
kernel/bpf/arraymap.c | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/kernel/bpf/arraymap.c b/kernel/bpf/arraymap.c
index 114fbda..f953acc 100644
--- a/kernel/bpf/arraymap.c
+++ b/kernel/bpf/arraymap.c
@@ -1096,20 +1096,20 @@ static struct bpf_map *prog_array_map_alloc(union bpf_attr *attr)
struct bpf_array_aux *aux;
struct bpf_map *map;
- aux = kzalloc(sizeof(*aux), GFP_KERNEL_ACCOUNT);
- if (!aux)
+ map = array_map_alloc(attr);
+ if (IS_ERR(map))
return ERR_PTR(-ENOMEM);
+ aux = bpf_map_kzalloc(map, sizeof(*aux), GFP_KERNEL);
+ if (!aux) {
+ array_map_free(map);
+ return ERR_PTR(-ENOMEM);
+ }
+
INIT_WORK(&aux->work, prog_array_map_clear_deferred);
INIT_LIST_HEAD(&aux->poke_progs);
mutex_init(&aux->poke_mutex);
- map = array_map_alloc(attr);
- if (IS_ERR(map)) {
- kfree(aux);
- return map;
- }
-
container_of(map, struct bpf_array, map)->aux = aux;
aux->map = map;
--
1.8.3.1
Powered by blists - more mailing lists