* [PATCH] selftests: futex: Fix missing free in main
@ 2024-09-04 2:55 zhangjiao2
2024-09-04 16:57 ` Shuah Khan
0 siblings, 1 reply; 2+ messages in thread
From: zhangjiao2 @ 2024-09-04 2:55 UTC (permalink / raw)
To: tglx; +Cc: mingo, shuah, linux-kernel, linux-kselftest, zhang jiao
From: zhang jiao <zhangjiao2@cmss.chinamobile.com>
Free string allocated by asprintf().
Signed-off-by: zhang jiao <zhangjiao2@cmss.chinamobile.com>
---
tools/testing/selftests/futex/functional/futex_requeue_pi.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/tools/testing/selftests/futex/functional/futex_requeue_pi.c b/tools/testing/selftests/futex/functional/futex_requeue_pi.c
index 215c6cb539b4..fb2dab46087f 100644
--- a/tools/testing/selftests/futex/functional/futex_requeue_pi.c
+++ b/tools/testing/selftests/futex/functional/futex_requeue_pi.c
@@ -416,5 +416,8 @@ int main(int argc, char *argv[])
ret = unit_test(broadcast, locked, owner, timeout_ns);
print_result(test_name, ret);
+ if (strlen(test_name) > strlen(TEST_NAME))
+ free(test_name);
+
return ret;
}
--
2.33.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] selftests: futex: Fix missing free in main
2024-09-04 2:55 [PATCH] selftests: futex: Fix missing free in main zhangjiao2
@ 2024-09-04 16:57 ` Shuah Khan
0 siblings, 0 replies; 2+ messages in thread
From: Shuah Khan @ 2024-09-04 16:57 UTC (permalink / raw)
To: zhangjiao2, tglx; +Cc: mingo, shuah, linux-kernel, linux-kselftest, Shuah Khan
On 9/3/24 20:55, zhangjiao2 wrote:
> From: zhang jiao <zhangjiao2@cmss.chinamobile.com>
>
> Free string allocated by asprintf().
How did you find this problem? Include the details in
the change log - The tool and output from the tool.
>
> Signed-off-by: zhang jiao <zhangjiao2@cmss.chinamobile.com>
> ---
> tools/testing/selftests/futex/functional/futex_requeue_pi.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/tools/testing/selftests/futex/functional/futex_requeue_pi.c b/tools/testing/selftests/futex/functional/futex_requeue_pi.c
> index 215c6cb539b4..fb2dab46087f 100644
> --- a/tools/testing/selftests/futex/functional/futex_requeue_pi.c
> +++ b/tools/testing/selftests/futex/functional/futex_requeue_pi.c
> @@ -416,5 +416,8 @@ int main(int argc, char *argv[])
> ret = unit_test(broadcast, locked, owner, timeout_ns);
>
> print_result(test_name, ret);
> + if (strlen(test_name) > strlen(TEST_NAME))
> + free(test_name);
Why not set a flag to determine if test_name needs freeing
instead of calling strlen() twice?
> +
> return ret;
> }
thanks,
-- Shuah
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-09-04 16:58 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-09-04 2:55 [PATCH] selftests: futex: Fix missing free in main zhangjiao2
2024-09-04 16:57 ` Shuah Khan
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox