From: Mike Rapoport <rppt@kernel.org>
To: Hongfu Li <lihongfu@kylinos.cn>
Cc: jgg@ziepe.ca, leon@kernel.org, akpm@linux-foundation.org,
david@kernel.org, ljs@kernel.org, vbabka@kernel.org,
surenb@google.com, mhocko@suse.com, shuah@kernel.org,
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 15:21:28 +0300 [thread overview]
Message-ID: <agMbSBgaBRoh2-xn@kernel.org> (raw)
In-Reply-To: <20260512101305.139509-1-lihongfu@kylinos.cn>
On Tue, May 12, 2026 at 06:13:05PM +0800, 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>
Acked-by: Mike Rapoport (Microsoft) <rppt@kernel.org>
> ---
> 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 */
> --
> 2.25.1
>
--
Sincerely yours,
Mike.
next prev parent reply other threads:[~2026-05-12 12:21 UTC|newest]
Thread overview: 7+ 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 [this message]
2026-05-12 12:57 ` Donet Tom
2026-05-12 14:06 ` Lorenzo Stoakes
2026-05-13 0:42 ` SeongJae Park
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=agMbSBgaBRoh2-xn@kernel.org \
--to=rppt@kernel.org \
--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=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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.