Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 81bae4ed authored by Patrick Daly's avatar Patrick Daly Committed by Gerrit - the friendly Code Review server
Browse files

ANDROID: mm/filemap: Fix missing put_page() for speculative page fault



find_get_page() returns a page with increased refcount, assuming a page
exists at the given index. Ensure this refcount is dropped on error.

Bug: 271079833
Fixes: 59d4d125 ("BACKPORT: FROMLIST: mm: implement speculative handling in filemap_fault()")
Change-Id: Idc7b9e3f11f32a02bed4c6f4e11cec9200a5c790
Signed-off-by: default avatarPatrick Daly <quic_pdaly@quicinc.com>
(cherry picked from commit 6232eecfa7ca0d8d0ca088da6d0edb2c3a879ff9)
Signed-off-by: default avatarZhenhua Huang <quic_zhenhuah@quicinc.com>
Git-commit: 1d05213028b6dbdb8801e20f29b6a6f91c216033
Git-repo: https://android.googlesource.com/kernel/common/


Signed-off-by: default avatarSrinivasarao Pathipati <quic_c_spathi@quicinc.com>
parent f350c4c6
Loading
Loading
Loading
Loading
+7 −2
Original line number Diff line number Diff line
@@ -2662,11 +2662,14 @@ vm_fault_t filemap_fault(struct vm_fault *vmf)

	if (vmf->flags & FAULT_FLAG_SPECULATIVE) {
		page = find_get_page(mapping, offset);
		if (unlikely(!page) || unlikely(PageReadahead(page)))
		if (unlikely(!page))
			return VM_FAULT_RETRY;

		if (unlikely(PageReadahead(page)))
			goto page_put;

		if (!trylock_page(page))
			return VM_FAULT_RETRY;
			goto page_put;

		if (unlikely(compound_head(page)->mapping != mapping))
			goto page_unlock;
@@ -2698,6 +2701,8 @@ vm_fault_t filemap_fault(struct vm_fault *vmf)
		return VM_FAULT_LOCKED;
page_unlock:
		unlock_page(page);
page_put:
		put_page(page);
		return VM_FAULT_RETRY;
	}