On 2021/8/8 2:46, akpm@xxxxxxxxxxxxxxxxxxxx wrote: > > The patch titled > Subject: mm-gup-fix-potential-pgmap-refcnt-leak-in-__gup_device_huge-fix-fix > has been added to the -mm tree. Its filename is > mm-gup-fix-potential-pgmap-refcnt-leak-in-__gup_device_huge-fix-fix.patch > > This patch should soon appear at > https://ozlabs.org/~akpm/mmots/broken-out/mm-gup-fix-potential-pgmap-refcnt-leak-in-__gup_device_huge-fix-fix.patch > and later at > https://ozlabs.org/~akpm/mmotm/broken-out/mm-gup-fix-potential-pgmap-refcnt-leak-in-__gup_device_huge-fix-fix.patch > > Before you just go and hit "reply", please: > a) Consider who else should be cc'ed > b) Prefer to cc a suitable mailing list as well > c) Ideally: find the original patch on the mailing list and do a > reply-to-all to that, adding suitable additional cc's > > *** Remember to use Documentation/process/submit-checklist.rst when testing your code *** > > The -mm tree is included into linux-next and is updated > there every 3-4 working days > > ------------------------------------------------------ > From: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> > Subject: mm-gup-fix-potential-pgmap-refcnt-leak-in-__gup_device_huge-fix-fix > > fix return value > > Cc: Claudio Imbrenda <imbrenda@xxxxxxxxxxxxx> > Cc: Jan Kara <jack@xxxxxxx> > Cc: John Hubbard <jhubbard@xxxxxxxxxx> > Cc: Kirill A. Shutemov <kirill.shutemov@xxxxxxxxxxxxxxx> > Cc: Miaohe Lin <linmiaohe@xxxxxxxxxx> > Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> > --- > > mm/gup.c | 5 ++++- > 1 file changed, 4 insertions(+), 1 deletion(-) > > --- 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; > } > Looks good to me. Many thanks for this improvement. :) > static int __gup_device_huge_pmd(pmd_t orig, pmd_t *pmdp, unsigned long addr, > _ >