LKML Archive on
help / color / mirror / Atom feed
From: Miguel Ojeda <>
To: Souptick Joarder <>
Cc: "Matthew Wilcox" <>,
	"Peter Zijlstra" <>,
	"Jérôme Glisse" <>,
	"Aneesh Kumar K.V" <>,
	"Huang Ying" <>,
	"open list" <>
Subject: [PATCH] mm: Fail when offset == num in first check of vm_map_pages_zero()
Date: Tue, 28 May 2019 22:05:40 +0200	[thread overview]
Message-ID: <> (raw)

If the user asks us for offset == num, we should already fail in the
first check, i.e. the one testing for offsets beyond the object.

At the moment, we are failing on the second test anyway,
since count cannot be 0. Still, to agree with the comment of the first
test, we should first there.

Signed-off-by: Miguel Ojeda <>
 mm/memory.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/mm/memory.c b/mm/memory.c
index ddf20bd0c317..74cf8b0ce353 100644
--- a/mm/memory.c
+++ b/mm/memory.c
@@ -1547,7 +1547,7 @@ static int __vm_map_pages(struct vm_area_struct *vma, struct page **pages,
 	int ret, i;
 	/* Fail if the user requested offset is beyond the end of the object */
-	if (offset > num)
+	if (offset >= num)
 		return -ENXIO;
 	/* Fail if the user requested size exceeds available object size */

             reply	other threads:[~2019-05-28 20:08 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-28 20:05 Miguel Ojeda [this message]
2019-05-29  7:09 ` Souptick Joarder
2019-06-01 10:41   ` Miguel Ojeda

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:

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \ \ \ \ \ \ \ \ \ \
    --subject='Re: [PATCH] mm: Fail when offset == num in first check of vm_map_pages_zero()' \

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

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).