diff mbox series

[bpf-next] selftests/bpf: Free strdup memory in xdp_hw_metadata

Message ID af9bcccb96655e82de5ce2b4510b88c9c8ed5ed0.1715417367.git.tanggeliang@kylinos.cn
State New
Headers show
Series [bpf-next] selftests/bpf: Free strdup memory in xdp_hw_metadata | expand

Commit Message

Geliang Tang May 11, 2024, 8:50 a.m. UTC
From: Geliang Tang <tanggeliang@kylinos.cn>

The strdup() function returns a pointer to a new string which is a
duplicate of the string "ifname". Memory for the new string is obtained
with malloc(), and need to be freed with free().

This patch adds this missing "free(saved_hwtstamp_ifname)" in cleanup()
to avoid a potential memory leak in xdp_hw_metadata.c.

Signed-off-by: Geliang Tang <tanggeliang@kylinos.cn>
---
 tools/testing/selftests/bpf/xdp_hw_metadata.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

patchwork-bot+netdevbpf@kernel.org May 13, 2024, 12:30 a.m. UTC | #1
Hello:

This patch was applied to bpf/bpf-next.git (master)
by Alexei Starovoitov <ast@kernel.org>:

On Sat, 11 May 2024 16:50:24 +0800 you wrote:
> From: Geliang Tang <tanggeliang@kylinos.cn>
> 
> The strdup() function returns a pointer to a new string which is a
> duplicate of the string "ifname". Memory for the new string is obtained
> with malloc(), and need to be freed with free().
> 
> This patch adds this missing "free(saved_hwtstamp_ifname)" in cleanup()
> to avoid a potential memory leak in xdp_hw_metadata.c.
> 
> [...]

Here is the summary with links:
  - [bpf-next] selftests/bpf: Free strdup memory in xdp_hw_metadata
    https://git.kernel.org/bpf/bpf-next/c/a3c1c95538e2

You are awesome, thank you!
diff mbox series

Patch

diff --git a/tools/testing/selftests/bpf/xdp_hw_metadata.c b/tools/testing/selftests/bpf/xdp_hw_metadata.c
index 0859fe727da7..6f9956eed797 100644
--- a/tools/testing/selftests/bpf/xdp_hw_metadata.c
+++ b/tools/testing/selftests/bpf/xdp_hw_metadata.c
@@ -581,6 +581,8 @@  static void cleanup(void)
 
 	if (bpf_obj)
 		xdp_hw_metadata__destroy(bpf_obj);
+
+	free((void *)saved_hwtstamp_ifname);
 }
 
 static void handle_signal(int sig)