[PATCH] selftests: ALSA: fix memory leak in utimer test

WangYuli posted 1 patch 2 months ago
tools/testing/selftests/alsa/utimer-test.c | 1 +
1 file changed, 1 insertion(+)
[PATCH] selftests: ALSA: fix memory leak in utimer test
Posted by WangYuli 2 months ago
Free the malloc'd buffer in TEST_F(timer_f, utimer) to prevent
memory leak.

Reported-by: Jun Zhan <zhanjun@uniontech.com>
Signed-off-by: WangYuli <wangyuli@uniontech.com>
---
 tools/testing/selftests/alsa/utimer-test.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/tools/testing/selftests/alsa/utimer-test.c b/tools/testing/selftests/alsa/utimer-test.c
index 32ee3ce57721..37964f311a33 100644
--- a/tools/testing/selftests/alsa/utimer-test.c
+++ b/tools/testing/selftests/alsa/utimer-test.c
@@ -135,6 +135,7 @@ TEST_F(timer_f, utimer) {
 	pthread_join(ticking_thread, NULL);
 	ASSERT_EQ(total_ticks, TICKS_COUNT);
 	pclose(rfp);
+	free(buf);
 }
 
 TEST(wrong_timers_test) {
-- 
2.50.1
Re: [PATCH] selftests: ALSA: fix memory leak in utimer test
Posted by Takashi Iwai 2 months ago
On Thu, 31 Jul 2025 12:02:22 +0200,
WangYuli wrote:
> 
> Free the malloc'd buffer in TEST_F(timer_f, utimer) to prevent
> memory leak.
> 
> Reported-by: Jun Zhan <zhanjun@uniontech.com>
> Signed-off-by: WangYuli <wangyuli@uniontech.com>

Thanks, applied now.  I added Fixes tag in my side.


Takashi

> ---
>  tools/testing/selftests/alsa/utimer-test.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/tools/testing/selftests/alsa/utimer-test.c b/tools/testing/selftests/alsa/utimer-test.c
> index 32ee3ce57721..37964f311a33 100644
> --- a/tools/testing/selftests/alsa/utimer-test.c
> +++ b/tools/testing/selftests/alsa/utimer-test.c
> @@ -135,6 +135,7 @@ TEST_F(timer_f, utimer) {
>  	pthread_join(ticking_thread, NULL);
>  	ASSERT_EQ(total_ticks, TICKS_COUNT);
>  	pclose(rfp);
> +	free(buf);
>  }
>  
>  TEST(wrong_timers_test) {
> -- 
> 2.50.1
>