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: 253068137
Fixes: cd333a037c ("BACKPORT: FROMLIST: mm: implement speculative handling in filemap_fault()")
Change-Id: Idc7b9e3f11f32a02bed4c6f4e11cec9200a5c790
Signed-off-by: Patrick Daly <quic_pdaly@quicinc.com>
This commit is contained in:
Patrick Daly
2022-10-10 19:25:27 -07:00
committed by Suren Baghdasaryan
parent 0555154508
commit 6232eecfa7

View File

@@ -3055,11 +3055,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;
@@ -3091,6 +3094,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;
}