mm/gup.c: Fix uninitialized return value on __gup_longterm_locked()
Subsystems (2)
PATCH 1/1 mm/gup.c: Fix uninitialized return value on __gup_longterm_locked()
From: Shigeru Yoshida <[email protected]>
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.
--- mm/gup.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
mm/gup.c +3 -1
@@ -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);
Signature · 1 line
2.37.2
Quoted 23 lines · Shigeru Yoshida
From: Shigeru Yoshida <[email protected]>
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 <[email protected]>Reported-by Dan Carpenter <[email protected]>Signed-off-by Shigeru Yoshida <[email protected]>--- mm/gup.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)mm/gup.c +0
-0@@ -2110,8 +2110,10 @@ static long __gup_longterm_locked(struct mm_struct *mm, nr_pinned_pages = __get_user_pages_locked(mm, start, nr_pages,
mm/gup.c static long __gup_longterm_locked(struct mm_struct *mm, · line 2119
Quoted 10 lines
mm/gup.c +3
-1pages, 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,
thanks,
Signature · 2 lines
John Hubbard NVIDIA