From: Shigeru Yoshida <syoshida@redhat.com>
To: akpm@linux-foundation.org
Cc: apopple@nvidia.com, jhubbard@nvidia.com, linux-mm@kvack.org,
linux-kernel@vger.kernel.org,
Shigeru Yoshida <yshigeru@gmail.com>,
Dan Carpenter <dan.carpenter@oracle.com>
Subject: [PATCH] mm/gup.c: Fix uninitialized return value on __gup_longterm_locked()
Date: Sun, 28 Aug 2022 08:00:37 +0900 [thread overview]
Message-ID: <20220827230037.78876-1-syoshida@redhat.com> (raw)
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
next reply other threads:[~2022-08-27 23:00 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-27 23:00 Shigeru Yoshida [this message]
2022-08-28 0:36 ` John Hubbard
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=20220827230037.78876-1-syoshida@redhat.com \
--to=syoshida@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=apopple@nvidia.com \
--cc=dan.carpenter@oracle.com \
--cc=jhubbard@nvidia.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=yshigeru@gmail.com \
/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