From: Sergey Matyukevich <geomatsi@gmail.com>
To: Wang Yan <wangyan01@kylinos.cn>
Cc: shuah@kernel.org, pjw@kernel.org, palmer@dabbelt.com,
aou@eecs.berkeley.edu, alex@ghiti.fr, andybnac@gmail.com,
andrew.jones@oss.qualcomm.com, thecharlesjenkins@gmail.com,
linux-kselftest@vger.kernel.org, linux-riscv@lists.infradead.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] selftests/riscv: ptrace: Fix memory leak of regset_data in vector tests
Date: Fri, 10 Jul 2026 13:16:02 +0300 [thread overview]
Message-ID: <alDGYu3qkX2B6J2_@curiosity> (raw)
In-Reply-To: <20260710083437.489648-1-wangyan01@kylinos.cn>
> The regset_data buffer allocated with calloc() in the parent process
> of several vector ptrace tests is never freed before returning,
> causing memory leaks in:
>
> - ptrace_v_not_enabled
> - ptrace_v_early_debug
> - ptrace_v_syscall_clobbering
> - v_csr_invalid/ptrace_v_invalid_values
> - v_csr_valid/ptrace_v_valid_values
>
> Add free(regset_data) before kill(pid, SIGKILL) to release the
> allocated buffer.
>
> Signed-off-by: Wang Yan <wangyan01@kylinos.cn>
> ---
> .../testing/selftests/riscv/vector/validate_v_ptrace.c | 10 +++++-----
> 1 file changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/tools/testing/selftests/riscv/vector/validate_v_ptrace.c b/tools/testing/selftests/riscv/vector/validate_v_ptrace.c
> index b038e2175c80..a388b7963d47 100644
> --- a/tools/testing/selftests/riscv/vector/validate_v_ptrace.c
> +++ b/tools/testing/selftests/riscv/vector/validate_v_ptrace.c
> @@ -75,7 +75,7 @@ TEST(ptrace_v_not_enabled)
> ASSERT_EQ(-1, ret);
>
> /* cleanup */
> -
> + free(regset_data);
> ASSERT_EQ(0, kill(pid, SIGKILL));
> }
> }
> @@ -207,7 +207,7 @@ TEST(ptrace_v_early_debug)
> EXPECT_EQ(vl_csr, regset_data->vl);
>
> /* cleanup */
> -
> + free(regset_data);
> ASSERT_EQ(0, kill(pid, SIGKILL));
> }
> }
> @@ -331,7 +331,7 @@ TEST(ptrace_v_syscall_clobbering)
> EXPECT_EQ(0UL, regset_data->vl);
>
> /* cleanup */
> -
> + free(regset_data);
> ASSERT_EQ(0, kill(pid, SIGKILL));
> }
> }
> @@ -649,7 +649,7 @@ TEST_F(v_csr_invalid, ptrace_v_invalid_values)
> ASSERT_EQ(ret, -1);
>
> /* cleanup */
> -
> + free(regset_data);
> ASSERT_EQ(0, kill(pid, SIGKILL));
> }
> }
> @@ -911,7 +911,7 @@ TEST_F(v_csr_valid, ptrace_v_valid_values)
> EXPECT_EQ(regset_data->vlenb, vlenb);
>
> /* cleanup */
> -
> + free(regset_data);
> ASSERT_EQ(0, kill(pid, SIGKILL));
> }
> }
Thanks !
Reviewed-by: Sergey Matyukevich <geomatsi@gmai.com>
Regards,
Sergey
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
next prev parent reply other threads:[~2026-07-10 10:16 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-10 8:34 [PATCH] selftests/riscv: ptrace: Fix memory leak of regset_data in vector tests Wang Yan
2026-07-10 10:16 ` Sergey Matyukevich [this message]
2026-07-10 15:38 ` Paul Walmsley
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=alDGYu3qkX2B6J2_@curiosity \
--to=geomatsi@gmail.com \
--cc=alex@ghiti.fr \
--cc=andrew.jones@oss.qualcomm.com \
--cc=andybnac@gmail.com \
--cc=aou@eecs.berkeley.edu \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=linux-riscv@lists.infradead.org \
--cc=palmer@dabbelt.com \
--cc=pjw@kernel.org \
--cc=shuah@kernel.org \
--cc=thecharlesjenkins@gmail.com \
--cc=wangyan01@kylinos.cn \
/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