Linux-mm Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Donet Tom <donettom@linux.ibm.com>
To: Hongfu Li <lihongfu@kylinos.cn>,
	jgg@ziepe.ca, leon@kernel.org, akpm@linux-foundation.org,
	david@kernel.org, ljs@kernel.org, vbabka@kernel.org,
	rppt@kernel.org, surenb@google.com, mhocko@suse.com,
	shuah@kernel.org
Cc: linux-mm@kvack.org, linux-kselftest@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] selftests/mm: Fix mmap() return value check in run_migration_benchmark
Date: Tue, 12 May 2026 18:27:53 +0530	[thread overview]
Message-ID: <6963c69e-5bb3-4ac5-96e4-38bc6085d29e@linux.ibm.com> (raw)
In-Reply-To: <20260512101305.139509-1-lihongfu@kylinos.cn>


On 5/12/26 3:43 PM, Hongfu Li wrote:
> mmap() returns MAP_FAILED on error, not NULL.  The current check uses
> !buffer->ptr, which evaluates to false when mmap() fails (since
> MAP_FAILED is (void *)-1, not 0), so the error path is never taken.
>
> Signed-off-by: Hongfu Li <lihongfu@kylinos.cn>


LGTM

Reviewed-by: Donet Tom <donettom@linux.ibm.com>

> ---
>   tools/testing/selftests/mm/hmm-tests.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/tools/testing/selftests/mm/hmm-tests.c b/tools/testing/selftests/mm/hmm-tests.c
> index 788689497e92..d72adba5c74e 100644
> --- a/tools/testing/selftests/mm/hmm-tests.c
> +++ b/tools/testing/selftests/mm/hmm-tests.c
> @@ -2688,7 +2688,7 @@ static inline int run_migration_benchmark(int fd, int use_thp, size_t buffer_siz
>   	buffer->ptr = mmap(NULL, buffer_size, PROT_READ | PROT_WRITE,
>   			  MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
>   
> -	if (!buffer->ptr)
> +	if (buffer->ptr == MAP_FAILED)
>   		return -1;
>   
>   	/* Apply THP hint if requested */


  parent reply	other threads:[~2026-05-12 12:58 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-12 10:13 [PATCH] selftests/mm: Fix mmap() return value check in run_migration_benchmark Hongfu Li
2026-05-12 10:33 ` David Hildenbrand (Arm)
2026-05-12 11:13 ` Dev Jain
2026-05-12 12:21 ` Mike Rapoport
2026-05-12 12:57 ` Donet Tom [this message]
2026-05-12 14:06 ` Lorenzo Stoakes

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=6963c69e-5bb3-4ac5-96e4-38bc6085d29e@linux.ibm.com \
    --to=donettom@linux.ibm.com \
    --cc=akpm@linux-foundation.org \
    --cc=david@kernel.org \
    --cc=jgg@ziepe.ca \
    --cc=leon@kernel.org \
    --cc=lihongfu@kylinos.cn \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=ljs@kernel.org \
    --cc=mhocko@suse.com \
    --cc=rppt@kernel.org \
    --cc=shuah@kernel.org \
    --cc=surenb@google.com \
    --cc=vbabka@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