[3/7] ubifs: Switch to page_mkwrite_check_truncate in ubifs_vm_page_mkwrite
diff mbox series

Message ID 20200213202423.23455-4-agruenba@redhat.com
State New
Headers show
Series
  • Switch to page_mkwrite_check_truncate
Related show

Commit Message

Andreas Gruenbacher Feb. 13, 2020, 8:24 p.m. UTC
Use the "page has been truncated" logic in page_mkwrite_check_truncate
instead of reimplementing it here.  Other than with the existing code,
fail with -EFAULT / VM_FAULT_NOPAGE when page_offset(page) == size here
as well, as should be expected.

Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
Acked-by: Richard Weinberger <richard@nod.at>
---
 fs/ubifs/file.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

Patch
diff mbox series

diff --git a/fs/ubifs/file.c b/fs/ubifs/file.c
index 743928efffc1..395ff2081ecb 100644
--- a/fs/ubifs/file.c
+++ b/fs/ubifs/file.c
@@ -1559,8 +1559,7 @@  static vm_fault_t ubifs_vm_page_mkwrite(struct vm_fault *vmf)
 	}
 
 	lock_page(page);
-	if (unlikely(page->mapping != inode->i_mapping ||
-		     page_offset(page) > i_size_read(inode))) {
+	if (unlikely(page_mkwrite_check_truncate(page, inode) < 0)) {
 		/* Page got truncated out from underneath us */
 		goto sigbus;
 	}