BPF List
 help / color / mirror / Atom feed
* [PATCH -next] bpf/btf: Use kvmemdup to simplify the code
@ 2024-08-27 11:29 Hongbo Li
  2024-08-27 20:42 ` Yonghong Song
  0 siblings, 1 reply; 2+ messages in thread
From: Hongbo Li @ 2024-08-27 11:29 UTC (permalink / raw)
  To: martin.lau, eddyz87, song, yonghong.song, john.fastabend, kpsingh,
	sdf, haoluo, jolsa
  Cc: bpf, lihongbo22

Use kvmemdup instead of kvmalloc() + memcpy() to simplify the
code.

No functional change intended.

Signed-off-by: Hongbo Li <lihongbo22@huawei.com>
---
 kernel/bpf/btf.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/kernel/bpf/btf.c b/kernel/bpf/btf.c
index 9d6f9924eca7..cbbc1c2bc62e 100644
--- a/kernel/bpf/btf.c
+++ b/kernel/bpf/btf.c
@@ -6238,12 +6238,11 @@ static struct btf *btf_parse_module(const char *module_name, const void *data,
 	btf->kernel_btf = true;
 	snprintf(btf->name, sizeof(btf->name), "%s", module_name);
 
-	btf->data = kvmalloc(data_size, GFP_KERNEL | __GFP_NOWARN);
+	btf->data = kvmemdup(data, data_size, GFP_KERNEL | __GFP_NOWARN);
 	if (!btf->data) {
 		err = -ENOMEM;
 		goto errout;
 	}
-	memcpy(btf->data, data, data_size);
 	btf->data_size = data_size;
 
 	err = btf_parse_hdr(env);
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH -next] bpf/btf: Use kvmemdup to simplify the code
  2024-08-27 11:29 [PATCH -next] bpf/btf: Use kvmemdup to simplify the code Hongbo Li
@ 2024-08-27 20:42 ` Yonghong Song
  0 siblings, 0 replies; 2+ messages in thread
From: Yonghong Song @ 2024-08-27 20:42 UTC (permalink / raw)
  To: Hongbo Li, martin.lau, eddyz87, song, john.fastabend, kpsingh,
	sdf, haoluo, jolsa
  Cc: bpf


On 8/27/24 4:29 AM, Hongbo Li wrote:
> Use kvmemdup instead of kvmalloc() + memcpy() to simplify the
> code.
>
> No functional change intended.
>
> Signed-off-by: Hongbo Li <lihongbo22@huawei.com>

For subject, please use [PATH bpf-next] instead of [PATH -next].
Other than this, LGTM.

Acked-by: Yonghong Song <yonghong.song@linux.dev>


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-08-27 20:42 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-08-27 11:29 [PATCH -next] bpf/btf: Use kvmemdup to simplify the code Hongbo Li
2024-08-27 20:42 ` Yonghong Song

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox