From 634dc83d5ca5a703865b17d87487d3923d41be43 Mon Sep 17 00:00:00 2001 From: Shweta Sodani Date: Mon, 4 Aug 2025 17:09:23 +0530 Subject: [PATCH] lib/util: Fix CID 1414760 - Memory leak local variable 't' is reusing in child process, resulting the leaking the tfork object as a side effect. This fixes coverity issue#1414760 Signed-off-by: Shweta Sodani Reviewed-by: Anoop C S Reviewed-by: Martin Schwenke Reviewed-by: Vinit Agnihotri Reviewed-by: Shachar Sharon Autobuild-User(master): Anoop C S Autobuild-Date(master): Tue Aug 12 09:32:19 UTC 2025 on atb-devel-224 --- lib/util/tests/tfork.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/util/tests/tfork.c b/lib/util/tests/tfork.c index 70ae97583fc..599ed7e4b52 100644 --- a/lib/util/tests/tfork.c +++ b/lib/util/tests/tfork.c @@ -373,14 +373,16 @@ static bool test_tfork_twice(struct torture_context *tctx) } child = tfork_child_pid(t); if (child == 0) { + struct tfork *t1 = NULL; + close(up[0]); - t = tfork_create(); - if (t == NULL) { + t1 = tfork_create(); + if (t1 == NULL) { torture_fail(tctx, "tfork failed\n"); return false; } - child = tfork_child_pid(t); + child = tfork_child_pid(t1); if (child == 0) { sleep(1); pid = getpid(); @@ -393,6 +395,8 @@ static bool test_tfork_twice(struct torture_context *tctx) _exit(1); } + status = tfork_status(&t1, true); + torture_assert_goto(tctx, status != -1, ok, done, "tfork_status failed\n"); _exit(0); } -- 2.47.2