Skip to content

Commit c7b6a56

Browse files
xzpetertorvalds
authored andcommitted
mm/gup: Mark lock taken only after a successful retake
It's definitely incorrect to mark the lock as taken even if down_read_killable() failed. This wass overlooked when we switched from down_read() to down_read_killable() because down_read() won't fail while down_read_killable() could. Fixes: 71335f3 ("mm/gup: allow to react to fatal signals") Reported-by: [email protected] Signed-off-by: Peter Xu <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent ba84107 commit c7b6a56

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

mm/gup.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1329,7 +1329,6 @@ static __always_inline long __get_user_pages_locked(struct task_struct *tsk,
13291329
if (fatal_signal_pending(current))
13301330
break;
13311331

1332-
*locked = 1;
13331332
ret = down_read_killable(&mm->mmap_sem);
13341333
if (ret) {
13351334
BUG_ON(ret > 0);
@@ -1338,6 +1337,7 @@ static __always_inline long __get_user_pages_locked(struct task_struct *tsk,
13381337
break;
13391338
}
13401339

1340+
*locked = 1;
13411341
ret = __get_user_pages(tsk, mm, start, 1, flags | FOLL_TRIED,
13421342
pages, NULL, locked);
13431343
if (!*locked) {

0 commit comments

Comments
 (0)