Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

selftests: net: fix memory leak in tls.c

To free memory and close fd after use

Suggested-by: Jun Zhan <zhanjun@uniontech.com>
Signed-off-by: Cryolitia PukNgae <cryolitia@uniontech.com>
Link: https://patch.msgid.link/20250819-memoryleak-v1-1-d4c70a861e62@uniontech.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Cryolitia PukNgae and committed by
Jakub Kicinski
e5b71dd3 07cf71bf

+5
+5
tools/testing/selftests/net/tls.c
··· 427 427 EXPECT_GE(filefd, 0); 428 428 fstat(filefd, &st); 429 429 EXPECT_GE(sendfile(self->fd, filefd, 0, st.st_size), 0); 430 + 431 + close(filefd); 430 432 } 431 433 432 434 TEST_F(tls, send_then_sendfile) ··· 450 448 451 449 EXPECT_GE(sendfile(self->fd, filefd, 0, st.st_size), 0); 452 450 EXPECT_EQ(recv(self->cfd, buf, st.st_size, MSG_WAITALL), st.st_size); 451 + 452 + free(buf); 453 + close(filefd); 453 454 } 454 455 455 456 static void chunked_sendfile(struct __test_metadata *_metadata,