* [PATCH] mm/gup.c: Fix uninitialized return value on __gup_longterm_locked()
@ 2022-08-27 23:00 Shigeru Yoshida
2022-08-28 0:36 ` John Hubbard
0 siblings, 1 reply; 2+ messages in thread
From: Shigeru Yoshida @ 2022-08-27 23:00 UTC (permalink / raw)
To: akpm
Cc: apopple, jhubbard, linux-mm, linux-kernel, Shigeru Yoshida,
Dan Carpenter
From: Shigeru Yoshida <yshigeru@gmail.com>
In __gup_longterm_locked(), it returns uninitialized value if
__get_user_pages_locked() fails on the first iteration of the loop
since rc is not initialized.
This patch fixes this issue by properly returning error code if
__get_user_pages_locked() fails.
Fixes: 11147539df44 (mm/gup.c: Fix return value for __gup_longterm_locked())
Cc: Alistair Popple <apopple@nvidia.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Shigeru Yoshida <yshigeru@gmail.com>
---
mm/gup.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/mm/gup.c b/mm/gup.c
index ad59c796d4d3..66d8619e02ad 100644
--- a/mm/gup.c
+++ b/mm/gup.c
@@ -2110,8 +2110,10 @@ static long __gup_longterm_locked(struct mm_struct *mm,
nr_pinned_pages = __get_user_pages_locked(mm, start, nr_pages,
pages, vmas, NULL,
gup_flags);
- if (nr_pinned_pages <= 0)
+ if (nr_pinned_pages <= 0) {
+ rc = nr_pinned_pages;
break;
+ }
rc = check_and_migrate_movable_pages(nr_pinned_pages, pages);
} while (rc == -EAGAIN);
memalloc_pin_restore(flags);
--
2.37.2
^ permalink raw reply [flat|nested] 2+ messages in thread* Re: [PATCH] mm/gup.c: Fix uninitialized return value on __gup_longterm_locked()
2022-08-27 23:00 [PATCH] mm/gup.c: Fix uninitialized return value on __gup_longterm_locked() Shigeru Yoshida
@ 2022-08-28 0:36 ` John Hubbard
0 siblings, 0 replies; 2+ messages in thread
From: John Hubbard @ 2022-08-28 0:36 UTC (permalink / raw)
To: Shigeru Yoshida, akpm
Cc: apopple, linux-mm, linux-kernel, Shigeru Yoshida, Dan Carpenter
On 8/27/22 16:00, Shigeru Yoshida wrote:
> From: Shigeru Yoshida <yshigeru@gmail.com>
>
> In __gup_longterm_locked(), it returns uninitialized value if
> __get_user_pages_locked() fails on the first iteration of the loop
> since rc is not initialized.
>
> This patch fixes this issue by properly returning error code if
> __get_user_pages_locked() fails.
>
> Fixes: 11147539df44 (mm/gup.c: Fix return value for __gup_longterm_locked())
> Cc: Alistair Popple <apopple@nvidia.com>
> Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
> Signed-off-by: Shigeru Yoshida <yshigeru@gmail.com>
> ---
> mm/gup.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/mm/gup.c b/mm/gup.c
> index ad59c796d4d3..66d8619e02ad 100644
> --- a/mm/gup.c
> +++ b/mm/gup.c
> @@ -2110,8 +2110,10 @@ static long __gup_longterm_locked(struct mm_struct *mm,
> nr_pinned_pages = __get_user_pages_locked(mm, start, nr_pages,
> pages, vmas, NULL,
> gup_flags);
> - if (nr_pinned_pages <= 0)
> + if (nr_pinned_pages <= 0) {
> + rc = nr_pinned_pages;
> break;
> + }
> rc = check_and_migrate_movable_pages(nr_pinned_pages, pages);
> } while (rc == -EAGAIN);
> memalloc_pin_restore(flags);
Sorry I didn't catch the 0th loop iteration problem on the
first review of this. Anyway,
Reviewed-by: John Hubbard <jhubbard@nvidia.com>
thanks,
--
John Hubbard
NVIDIA
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-08-28 0:37 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-27 23:00 [PATCH] mm/gup.c: Fix uninitialized return value on __gup_longterm_locked() Shigeru Yoshida
2022-08-28 0:36 ` John Hubbard
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox