Skip to content

Commit a3c1c95

Browse files
Geliang TangAlexei Starovoitov
authored andcommitted
selftests/bpf: Free strdup memory in xdp_hw_metadata
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 <[email protected]> Link: https://lore.kernel.org/r/af9bcccb96655e82de5ce2b4510b88c9c8ed5ed0.1715417367.git.tanggeliang@kylinos.cn Signed-off-by: Alexei Starovoitov <[email protected]>
1 parent 5ddafcc commit a3c1c95

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

tools/testing/selftests/bpf/xdp_hw_metadata.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -581,6 +581,8 @@ static void cleanup(void)
581581

582582
if (bpf_obj)
583583
xdp_hw_metadata__destroy(bpf_obj);
584+
585+
free((void *)saved_hwtstamp_ifname);
584586
}
585587

586588
static void handle_signal(int sig)

0 commit comments

Comments
 (0)