projects
/
linux-block.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
12c8d0f
)
bpf: Simplify code of destroy_mem_alloc() with kmemdup().
author
Alexei Starovoitov
<ast@kernel.org>
Thu, 6 Jul 2023 03:34:35 +0000
(20:34 -0700)
committer
Daniel Borkmann
<daniel@iogearbox.net>
Wed, 12 Jul 2023 21:45:22 +0000
(23:45 +0200)
Use kmemdup() to simplify the code.
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Hou Tao <houtao1@huawei.com>
Link:
https://lore.kernel.org/bpf/20230706033447.54696-3-alexei.starovoitov@gmail.com
kernel/bpf/memalloc.c
patch
|
blob
|
blame
|
history
diff --git
a/kernel/bpf/memalloc.c
b/kernel/bpf/memalloc.c
index cc5b8adb4c83c5fa03bc70f05cd555baa092ff59..b0011217be6c953e5913cd8a8fad322c2fc537e4 100644
(file)
--- a/
kernel/bpf/memalloc.c
+++ b/
kernel/bpf/memalloc.c
@@
-499,7
+499,7
@@
static void destroy_mem_alloc(struct bpf_mem_alloc *ma, int rcu_in_progress)
return;
}
- copy = km
alloc(
sizeof(*ma), GFP_KERNEL);
+ copy = km
emdup(ma,
sizeof(*ma), GFP_KERNEL);
if (!copy) {
/* Slow path with inline barrier-s */
free_mem_alloc(ma);
@@
-507,10
+507,7
@@
static void destroy_mem_alloc(struct bpf_mem_alloc *ma, int rcu_in_progress)
}
/* Defer barriers into worker to let the rest of map memory to be freed */
- copy->cache = ma->cache;
- ma->cache = NULL;
- copy->caches = ma->caches;
- ma->caches = NULL;
+ memset(ma, 0, sizeof(*ma));
INIT_WORK(©->work, free_mem_alloc_deferred);
queue_work(system_unbound_wq, ©->work);
}