linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: David Hildenbrand <david@redhat.com>
To: liuye <liuye@kylinos.cn>, akpm@linux-foundation.org, shuah@kernel.org
Cc: linux-mm@kvack.org, linux-kselftest@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] selftests/mm/mkdirty: Fix memory leak in test_uffdio_copy()
Date: Tue, 14 Jan 2025 11:21:16 +0100	[thread overview]
Message-ID: <ffe62886-ddaa-4623-88d1-5ce1e6f3632e@redhat.com> (raw)
In-Reply-To: <20250114023838.48589-1-liuye@kylinos.cn>

On 14.01.25 03:38, liuye wrote:
>      Release memory before exception branch returns to prevent memory leaks
> 
> Checking tools/testing/selftests/mm/mkdirty.c ...
> tools/testing/selftests/mm/mkdirty.c:283:3: error: Memory leak: src [memleak]
>    return;
>    ^

Don't take this the wrong way: there must be something better to be done 
with your time than fixing memory leaks on exit paths in tests.

> 
> Signed-off-by: liuye <liuye@kylinos.cn>
> ---
>   tools/testing/selftests/mm/mkdirty.c | 1 +
>   1 file changed, 1 insertion(+)
> 
> diff --git a/tools/testing/selftests/mm/mkdirty.c b/tools/testing/selftests/mm/mkdirty.c
> index 1db134063c38..af2fce496912 100644
> --- a/tools/testing/selftests/mm/mkdirty.c
> +++ b/tools/testing/selftests/mm/mkdirty.c
> @@ -280,6 +280,7 @@ static void test_uffdio_copy(void)
>   	dst = mmap(NULL, pagesize, PROT_READ, MAP_PRIVATE|MAP_ANON, -1, 0);
>   	if (dst == MAP_FAILED) {
>   		ksft_test_result_fail("mmap() failed\n");
> +		free(src);


We are immediately exiting the test afterwards ...

In any case, the change LGTM

Reviewed-by: David Hildenbrand <david@redhat.com>

-- 
Cheers,

David / dhildenb



      reply	other threads:[~2025-01-14 10:21 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-14  2:38 liuye
2025-01-14 10:21 ` David Hildenbrand [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=ffe62886-ddaa-4623-88d1-5ce1e6f3632e@redhat.com \
    --to=david@redhat.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=liuye@kylinos.cn \
    --cc=shuah@kernel.org \
    /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