From 33762753f0373ec525d0351c1bcce75e68227d73 Mon Sep 17 00:00:00 2001 From: Shweta Sodani Date: Mon, 22 Sep 2025 14:36:58 +0530 Subject: [PATCH] lib/util: Fix CID 1414760 - Resource leak If read is failed torture_assert could return without freeing the t. Fixing the leak. Signed-off-by: Shweta Sodani Reviewed-by: Volker Lendecke Reviewed-by: Vinit Agnihotri Reviewed-by: Anoop C S Autobuild-User(master): Anoop C S Autobuild-Date(master): Sun Sep 28 09:30:56 UTC 2025 on atb-devel-224 --- lib/util/tests/tfork.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/util/tests/tfork.c b/lib/util/tests/tfork.c index 599ed7e4b52..19237a5156f 100644 --- a/lib/util/tests/tfork.c +++ b/lib/util/tests/tfork.c @@ -403,7 +403,7 @@ static bool test_tfork_twice(struct torture_context *tctx) close(up[1]); ret = read(up[0], &pid, sizeof(pid_t)); - torture_assert(tctx, ret == sizeof(pid_t), "read failed\n"); + torture_assert_goto(tctx, ret == sizeof(pid_t), ok, done, "read failed\n"); status = tfork_status(&t, true); torture_assert_goto(tctx, status != -1, ok, done, "tfork_status failed\n"); @@ -413,6 +413,10 @@ static bool test_tfork_twice(struct torture_context *tctx) torture_assert_goto(tctx, WEXITSTATUS(status) == 0, ok, done, "tfork failed\n"); done: + if (t != NULL) { + kill(child, SIGKILL); + free(t); + } return ok; } -- 2.47.3