From: Wei Yang <richard.weiyang@gmail.com>
To: akpm@linux-foundation.org
Cc: linux-mm@kvack.org, Wei Yang <richard.weiyang@gmail.com>,
David Hildenbrand <david@redhat.com>,
Lorenzo Stoakes <lorenzo.stoakes@oracle.com>,
Rik van Riel <riel@surriel.com>,
"Liam R . Howlett" <Liam.Howlett@oracle.com>,
Vlastimil Babka <vbabka@suse.cz>,
Harry Yoo <harry.yoo@oracle.com>
Subject: [PATCH 1/3] selftests/mm: check a valid fd with negative value
Date: Wed, 16 Jul 2025 08:27:08 +0000 [thread overview]
Message-ID: <20250716082710.2801-2-richard.weiyang@gmail.com> (raw)
In-Reply-To: <20250716082710.2801-1-richard.weiyang@gmail.com>
fd 0 is usually occupied by stdin, which is not expected to be returned
by open(). But 0 is still a valid fd.
Check the valid fd with negative value like other places.
Signed-off-by: Wei Yang <richard.weiyang@gmail.com>
Cc: David Hildenbrand <david@redhat.com>
Cc: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
Cc: Rik van Riel <riel@surriel.com>
Cc: Liam R. Howlett <Liam.Howlett@oracle.com>
Cc: Vlastimil Babka <vbabka@suse.cz>
Cc: Harry Yoo <harry.yoo@oracle.com>
---
tools/testing/selftests/mm/ksm_functional_tests.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/testing/selftests/mm/ksm_functional_tests.c b/tools/testing/selftests/mm/ksm_functional_tests.c
index d8bd1911dfc0..6da5c3340e10 100644
--- a/tools/testing/selftests/mm/ksm_functional_tests.c
+++ b/tools/testing/selftests/mm/ksm_functional_tests.c
@@ -81,7 +81,7 @@ static long get_my_ksm_zero_pages(void)
ssize_t read_size;
unsigned long my_ksm_zero_pages;
- if (!proc_self_ksm_stat_fd)
+ if (proc_self_ksm_stat_fd < 0)
return 0;
read_size = pread(proc_self_ksm_stat_fd, buf, sizeof(buf) - 1, 0);
--
2.34.1
next prev parent reply other threads:[~2025-07-16 8:27 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-16 8:27 [PATCH 0/3] selftests/mm: assert rmap behave as expected Wei Yang
2025-07-16 8:27 ` Wei Yang [this message]
2025-07-16 8:52 ` [PATCH 1/3] selftests/mm: check a valid fd with negative value David Hildenbrand
2025-07-17 1:18 ` Wei Yang
2025-07-17 8:27 ` David Hildenbrand
2025-07-16 8:27 ` [PATCH 2/3] selftests/mm: put general ksm operation into vm_util Wei Yang
2025-07-16 9:20 ` David Hildenbrand
2025-07-17 2:45 ` Wei Yang
2025-07-17 3:30 ` Wei Yang
2025-07-17 11:57 ` David Hildenbrand
2025-07-17 11:56 ` David Hildenbrand
2025-07-16 8:27 ` [PATCH 3/3] selftests/mm: assert rmap behave as expected Wei Yang
2025-07-16 13:34 ` David Hildenbrand
2025-07-17 3:17 ` Wei Yang
2025-07-25 2:16 ` Wei Yang
2025-07-25 13:34 ` David Hildenbrand
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=20250716082710.2801-2-richard.weiyang@gmail.com \
--to=richard.weiyang@gmail.com \
--cc=Liam.Howlett@oracle.com \
--cc=akpm@linux-foundation.org \
--cc=david@redhat.com \
--cc=harry.yoo@oracle.com \
--cc=linux-mm@kvack.org \
--cc=lorenzo.stoakes@oracle.com \
--cc=riel@surriel.com \
--cc=vbabka@suse.cz \
/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;
as well as URLs for NNTP newsgroup(s).