On Tue, Aug 26, 2025 at 11:15:40AM +0800, Zongmin Zhou wrote: > From: Zongmin Zhou <zhouzong...@kylinos.cn> > > The buffer be used without free,fix it to avoid memory leak.
I'm assuming this is a short-lived user-space program. And any memory is freed when it exits. So I'm unsure about the value of this change. > > Signed-off-by: Zongmin Zhou <zhouzong...@kylinos.cn> > --- > tools/testing/selftests/net/cmsg_sender.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/tools/testing/selftests/net/cmsg_sender.c > b/tools/testing/selftests/net/cmsg_sender.c > index a825e628aee7..5358aa09ecb9 100644 > --- a/tools/testing/selftests/net/cmsg_sender.c > +++ b/tools/testing/selftests/net/cmsg_sender.c > @@ -491,6 +491,7 @@ int main(int argc, char *argv[]) > if (err) { > fprintf(stderr, "Can't resolve address [%s]:%s\n", > opt.host, opt.service); > + free(buf); > return ERN_SOCK_CREATE; > } > > @@ -501,6 +502,7 @@ int main(int argc, char *argv[]) > if (fd < 0) { > fprintf(stderr, "Can't open socket: %s\n", strerror(errno)); > freeaddrinfo(ai); > + free(buf); > return ERN_RESOLVE; > } > > @@ -575,5 +577,6 @@ int main(int argc, char *argv[]) > err_out: > close(fd); > freeaddrinfo(ai); I think it would be nicer to add another label here, say err_free_buff, and then use it in the previous two hunks. > + free(buf); > return err; > } > -- > 2.34.1 >