[patch 02/31] mm/gup: finish consolidating error handling

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: John Hubbard <jhubbard@xxxxxxxxxx>
Subject: mm/gup: finish consolidating error handling

df06b37ffe5a4 ("mm/gup: cache dev_pagemap while pinning pages") attempted
to operate on each page that get_user_pages had retrieved.  In order to do
that, it created a common exit point from the routine.  However, one case
was missed, which this patch fixes up.

Also, there was still an unnecessary shadow declaration (with a different
type) of the "ret" variable, which this patch removes.

Keith's description of the situation is:

  This also fixes a potentially leaked dev_pagemap reference count if a
  failure occurs when an iteration crosses a vma boundary.  I don't think
  it's normal to have different vma's on a users mapped zone device
  memory, but good to fix anyway.

I actually thought that this code:

    /* first iteration or cross vma bound */
    if (!vma || start >= vma->vm_end) {
	        vma = find_extend_vma(mm, start);
	        if (!vma && in_gate_area(mm, start)) {
		            ret = get_gate_page(mm, start & PAGE_MASK,
		                    gup_flags, &vma,
		                    pages ? &pages[i] : NULL);
		            if (ret)
		                goto out;

dealt with the "you're trying to pin the gate page, as part of this call",
rather than the generic case of crossing a vma boundary.  (I think there's
a fine point that I must be overlooking.) But it's still a valid case,
either way.  

Link: http://lkml.kernel.org/r/20181121081402.29641-2-jhubbard@xxxxxxxxxx
Fixes: df06b37ffe5a4 ("mm/gup: cache dev_pagemap while pinning pages")
Signed-off-by: John Hubbard <jhubbard@xxxxxxxxxx>
Reviewed-by: Keith Busch <keith.busch@xxxxxxxxx>
Cc: Dan Williams <dan.j.williams@xxxxxxxxx>
Cc: Kirill A. Shutemov <kirill.shutemov@xxxxxxxxxxxxxxx>
Cc: Dave Hansen <dave.hansen@xxxxxxxxx>
Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>
---

 mm/gup.c |    3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

--- a/mm/gup.c~mm-gup-finish-consolidating-error-handling
+++ a/mm/gup.c
@@ -702,12 +702,11 @@ static long __get_user_pages(struct task
 		if (!vma || start >= vma->vm_end) {
 			vma = find_extend_vma(mm, start);
 			if (!vma && in_gate_area(mm, start)) {
-				int ret;
 				ret = get_gate_page(mm, start & PAGE_MASK,
 						gup_flags, &vma,
 						pages ? &pages[i] : NULL);
 				if (ret)
-					return i ? : ret;
+					goto out;
 				ctx.page_mask = 0;
 				goto next_page;
 			}
_



[Index of Archives]     [Kernel Archive]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]

  Powered by Linux