linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: John Hubbard <jhubbard@nvidia.com>
To: Andrew Morton <akpm@linux-foundation.org>,
	Miaohe Lin <linmiaohe@huawei.com>, <imbrenda@linux.ibm.com>,
	<kirill.shutemov@linux.intel.com>, <jack@suse.cz>,
	<linux-mm@kvack.org>, <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 4/5] mm: gup: fix potential pgmap refcnt leak in __gup_device_huge()
Date: Sun, 8 Aug 2021 14:16:53 -0700	[thread overview]
Message-ID: <87f2ff42-9d96-3ecb-dada-d347a3fa95e6@nvidia.com> (raw)
In-Reply-To: <20210807114545.eaee318909a9215c4e056aa3@linux-foundation.org>

On 8/7/21 11:45 AM, Andrew Morton wrote:
> On Sat, 7 Aug 2021 11:41:12 -0700 Andrew Morton <akpm@linux-foundation.org> wrote:
> 
>> We can simplify further, and remove the troublesome multiple return points?
>>
> 
> oops.

I sent a reviewed by to the "+" fixup email, but just realized that that did not
hit the main
  mailing list. So:



For the end result of these stacked fixes to this file:



Reviewed-by: John Hubbard <jhubbard@nvidia.com>



thanks,

-- 

John Hubbard

NVIDIA
> 
> --- a/mm/gup.c~mm-gup-fix-potential-pgmap-refcnt-leak-in-__gup_device_huge-fix-fix
> +++ a/mm/gup.c
> @@ -2240,6 +2240,7 @@ static int __gup_device_huge(unsigned lo
>   {
>   	int nr_start = *nr;
>   	struct dev_pagemap *pgmap = NULL;
> +	int ret = 1;
>   
>   	do {
>   		struct page *page = pfn_to_page(pfn);
> @@ -2247,12 +2248,14 @@ static int __gup_device_huge(unsigned lo
>   		pgmap = get_dev_pagemap(pfn, pgmap);
>   		if (unlikely(!pgmap)) {
>   			undo_dev_pagemap(nr, nr_start, flags, pages);
> +			ret = 0;
>   			break;
>   		}
>   		SetPageReferenced(page);
>   		pages[*nr] = page;
>   		if (unlikely(!try_grab_page(page, flags))) {
>   			undo_dev_pagemap(nr, nr_start, flags, pages);
> +			ret = 0;
>   			break;
>   		}
>   		(*nr)++;
> @@ -2260,7 +2263,7 @@ static int __gup_device_huge(unsigned lo
>   	} while (addr += PAGE_SIZE, addr != end);
>   
>   	put_dev_pagemap(pgmap);
> -	return 1;
> +	return ret;
>   }
>   
>   static int __gup_device_huge_pmd(pmd_t orig, pmd_t *pmdp, unsigned long addr,
> 
> Not sure if it's worth bothering, really...
> 


  reply	other threads:[~2021-08-08 21:17 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-07  9:36 [PATCH 0/5] Cleanups and fixup for gup Miaohe Lin
2021-08-07  9:36 ` [PATCH 1/5] mm: gup: remove set but unused local variable major Miaohe Lin
2021-08-09  9:21   ` David Hildenbrand
2021-08-07  9:36 ` [PATCH 2/5] mm: gup: remove unneed local variable orig_refs Miaohe Lin
2021-08-09  9:22   ` David Hildenbrand
2021-08-07  9:36 ` [PATCH 3/5] mm: gup: remove useless BUG_ON in __get_user_pages() Miaohe Lin
2021-08-09  9:23   ` David Hildenbrand
2021-08-07  9:36 ` [PATCH 4/5] mm: gup: fix potential pgmap refcnt leak in __gup_device_huge() Miaohe Lin
2021-08-07 18:41   ` Andrew Morton
2021-08-07 18:45     ` Andrew Morton
2021-08-08 21:16       ` John Hubbard [this message]
2021-08-07  9:36 ` [PATCH 5/5] mm: gup: use helper PAGE_ALIGNED in populate_vma_page_range() Miaohe Lin
2021-08-09  9:24   ` David Hildenbrand
2021-08-08 21:13 ` [PATCH 0/5] Cleanups and fixup for gup John Hubbard
2021-08-09  9:39 ` Claudio Imbrenda

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=87f2ff42-9d96-3ecb-dada-d347a3fa95e6@nvidia.com \
    --to=jhubbard@nvidia.com \
    --cc=akpm@linux-foundation.org \
    --cc=imbrenda@linux.ibm.com \
    --cc=jack@suse.cz \
    --cc=kirill.shutemov@linux.intel.com \
    --cc=linmiaohe@huawei.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    /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).