• John Hubbard's avatar
    mm/gup: finish consolidating error handling · 08be37b7
    John Hubbard authored
    Commit df06b37f ("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,
    		                ...
    08be37b7
gup.c 51.3 KB