Skip to content

Commit

Permalink
mm/memory.c: fail when offset == num in first check of __vm_map_pages()
Browse files Browse the repository at this point in the history
If the caller 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 test it there.

Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Miguel Ojeda <[email protected]>
Reviewed-by: Andrew Morton <[email protected]>
Cc: Souptick Joarder <[email protected]>
Cc: Matthew Wilcox <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: "Aneesh Kumar K.V" <[email protected]>
Cc: Huang Ying <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
ojeda authored and torvalds committed Jul 12, 2019
1 parent 8b1e0f8 commit 96756fc
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion mm/memory.c
Original file line number Diff line number Diff line change
Expand Up @@ -1545,7 +1545,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 */
Expand Down

0 comments on commit 96756fc

Please sign in to comment.