Skip to content

Commit c6d9daf

Browse files
Hongbo LiAlexei Starovoitov
authored andcommitted
bpf: Use kvmemdup to simplify the code
Use kvmemdup instead of kvmalloc() + memcpy() to simplify the code. No functional change intended. Acked-by: Yonghong Song <[email protected]> Signed-off-by: Hongbo Li <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Alexei Starovoitov <[email protected]>
1 parent 89dd9bb commit c6d9daf

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

kernel/bpf/btf.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6272,12 +6272,11 @@ static struct btf *btf_parse_module(const char *module_name, const void *data,
62726272
btf->kernel_btf = true;
62736273
snprintf(btf->name, sizeof(btf->name), "%s", module_name);
62746274

6275-
btf->data = kvmalloc(data_size, GFP_KERNEL | __GFP_NOWARN);
6275+
btf->data = kvmemdup(data, data_size, GFP_KERNEL | __GFP_NOWARN);
62766276
if (!btf->data) {
62776277
err = -ENOMEM;
62786278
goto errout;
62796279
}
6280-
memcpy(btf->data, data, data_size);
62816280
btf->data_size = data_size;
62826281

62836282
err = btf_parse_hdr(env);

0 commit comments

Comments
 (0)