From: Cryolitia PukNgae <cryoli...@uniontech.com>

To free memory and close fd after use

Suggested-by: Jun Zhan <zhan...@uniontech.com>
Signed-off-by: Cryolitia PukNgae <cryoli...@uniontech.com>
---
 tools/testing/selftests/net/tls.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/tools/testing/selftests/net/tls.c 
b/tools/testing/selftests/net/tls.c
index 
d8cfcf9bb82594ca078c998ce5849131bf46ade8..23cf6ff5fa49378bd7906334ff402aa61a205f29
 100644
--- a/tools/testing/selftests/net/tls.c
+++ b/tools/testing/selftests/net/tls.c
@@ -427,6 +427,8 @@ TEST_F(tls, sendfile)
        EXPECT_GE(filefd, 0);
        fstat(filefd, &st);
        EXPECT_GE(sendfile(self->fd, filefd, 0, st.st_size), 0);
+
+       close(filefd);
 }
 
 TEST_F(tls, send_then_sendfile)
@@ -448,6 +450,9 @@ TEST_F(tls, send_then_sendfile)
 
        EXPECT_GE(sendfile(self->fd, filefd, 0, st.st_size), 0);
        EXPECT_EQ(recv(self->cfd, buf, st.st_size, MSG_WAITALL), st.st_size);
+
+       free(buf);
+       close(filefd);
 }
 
 static void chunked_sendfile(struct __test_metadata *_metadata,

---
base-commit: be48bcf004f9d0c9207ff21d0edb3b42f253829e
change-id: 20250819-memoryleak-9dbec9af6c07

Best regards,
-- 
Cryolitia PukNgae <cryoli...@uniontech.com>



Reply via email to