From: Shuah Khan <skhan@linuxfoundation.org>
To: zhangjiao2 <zhangjiao2@cmss.chinamobile.com>
Cc: linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org,
mingo@redhat.com, shuah@kernel.org, tglx@linutronix.de,
Shuah Khan <skhan@linuxfoundation.org>
Subject: Re: [PATCH v2] selftests: futex: Fix missing free in main
Date: Thu, 5 Sep 2024 14:08:58 -0600 [thread overview]
Message-ID: <88a9bf6d-099a-43fc-ac71-b12380ae586e@linuxfoundation.org> (raw)
In-Reply-To: <20240905020125.2830-1-zhangjiao2@cmss.chinamobile.com>
On 9/4/24 20:01, zhangjiao2 wrote:
> From: zhang jiao <zhangjiao2@cmss.chinamobile.com>
>
> By readind the code, I found there is no free() after asprintf().
> Just free it.
>
> Signed-off-by: zhang jiao <zhangjiao2@cmss.chinamobile.com>
> ---
> v1->v2:
> Set a flag to determine if test_name needs free.
>
> tools/testing/selftests/futex/functional/futex_requeue_pi.c | 4 ++++
> 1 file changed, 4 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..d78bb5112fce 100644
> --- a/tools/testing/selftests/futex/functional/futex_requeue_pi.c
> +++ b/tools/testing/selftests/futex/functional/futex_requeue_pi.c
> @@ -362,6 +362,7 @@ int main(int argc, char *argv[])
> {
> char *test_name;
> int c, ret;
> + int need_f = 1;
This can be a bool which - better to set it to false as a initial
value.
>
> while ((c = getopt(argc, argv, "bchlot:v:")) != -1) {
> switch (c) {
> @@ -404,6 +405,7 @@ int main(int argc, char *argv[])
> "%s broadcast=%d locked=%d owner=%d timeout=%ldns",
> TEST_NAME, broadcast, locked, owner, timeout_ns);
> if (ret < 0) {
> + need_f = 0;
You would set it to TRUE here.
> ksft_print_msg("Failed to generate test name\n");
> test_name = TEST_NAME;
> }
> @@ -416,5 +418,7 @@ int main(int argc, char *argv[])
> ret = unit_test(broadcast, locked, owner, timeout_ns);
>
> print_result(test_name, ret);
> + if (need_f)
Check against TRUE
> + free(test_name);
> return ret;
> }
thanks,
-- Shuah
prev parent reply other threads:[~2024-09-05 20:09 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-09-05 2:01 [PATCH v2] selftests: futex: Fix missing free in main zhangjiao2
2024-09-05 20:08 ` Shuah Khan [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=88a9bf6d-099a-43fc-ac71-b12380ae586e@linuxfoundation.org \
--to=skhan@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=shuah@kernel.org \
--cc=tglx@linutronix.de \
--cc=zhangjiao2@cmss.chinamobile.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox