projects
/
linux.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
84ef3f0
)
bpf: Use kmemdup() to replace kmalloc + memcpy
author
Jiapeng Chong
<jiapeng.chong@linux.alibaba.com>
Thu, 9 Dec 2021 06:21:22 +0000
(14:21 +0800)
committer
Alexei Starovoitov
<ast@kernel.org>
Sun, 12 Dec 2021 01:57:33 +0000
(17:57 -0800)
Eliminate the follow coccicheck warning:
./kernel/bpf/btf.c:6537:13-20: WARNING opportunity for kmemdup.
Reported-by: Abaci Robot <abaci@linux.alibaba.com>
Signed-off-by: Jiapeng Chong <jiapeng.chong@linux.alibaba.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Link:
https://lore.kernel.org/bpf/1639030882-92383-1-git-send-email-jiapeng.chong@linux.alibaba.com
kernel/bpf/btf.c
patch
|
blob
|
history
diff --git
a/kernel/bpf/btf.c
b/kernel/bpf/btf.c
index 8b00c6e4d6fb7f7c7a2a6e816aef3a1477816bc9..baa90f3acd4193fae52ad95da272135f7a6f6488 100644
(file)
--- a/
kernel/bpf/btf.c
+++ b/
kernel/bpf/btf.c
@@
-6534,12
+6534,11
@@
static struct bpf_cand_cache *populate_cand_cache(struct bpf_cand_cache *cands,
bpf_free_cands_from_cache(*cc);
*cc = NULL;
}
- new_cands = km
alloc(
sizeof_cands(cands->cnt), GFP_KERNEL);
+ new_cands = km
emdup(cands,
sizeof_cands(cands->cnt), GFP_KERNEL);
if (!new_cands) {
bpf_free_cands(cands);
return ERR_PTR(-ENOMEM);
}
- memcpy(new_cands, cands, sizeof_cands(cands->cnt));
/* strdup the name, since it will stay in cache.
* the cands->name points to strings in prog's BTF and the prog can be unloaded.
*/