Luís Henriques 3b4d29
From: "Matthew Wilcox (Oracle)" <willy@infradead.org>
Luís Henriques 3b4d29
Date: Mon, 26 Oct 2020 09:12:10 +0000
Luís Henriques 3b4d29
Subject: cachefiles: Handle readpage error correctly
Luís Henriques 3b4d29
Git-commit: 9480b4e75b7108ee68ecf5bc6b4bd68e8031c521
Luís Henriques 3b4d29
Patch-mainline: v5.10-rc2
Luís Henriques 3b4d29
References: bsc#1210430
Luís Henriques 3b4d29
Luís Henriques 3b4d29
If ->readpage returns an error, it has already unlocked the page.
Luís Henriques 3b4d29
Luís Henriques 3b4d29
Fixes: 5e929b33c393 ("CacheFiles: Handle truncate unlocking the page we're reading")
Luís Henriques 3b4d29
Cc: stable@vger.kernel.org
Luís Henriques 3b4d29
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Luís Henriques 3b4d29
Signed-off-by: David Howells <dhowells@redhat.com>
Luís Henriques 3b4d29
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Luís Henriques 3b4d29
Acked-by: Luís Henriques <lhenriques@suse.de>
Luís Henriques 3b4d29
Luís Henriques 3b4d29
---
Luís Henriques 3b4d29
 fs/cachefiles/rdwr.c | 3 ++-
Luís Henriques 3b4d29
 1 file changed, 2 insertions(+), 1 deletion(-)
Luís Henriques 3b4d29
Luís Henriques 3b4d29
diff --git a/fs/cachefiles/rdwr.c b/fs/cachefiles/rdwr.c
Luís Henriques 3b4d29
index 3080cda9e824..8bda092e60c5 100644
Luís Henriques 3b4d29
--- a/fs/cachefiles/rdwr.c
Luís Henriques 3b4d29
+++ b/fs/cachefiles/rdwr.c
Luís Henriques 3b4d29
@@ -121,7 +121,7 @@ static int cachefiles_read_reissue(struct cachefiles_object *object,
Luís Henriques 3b4d29
 		_debug("reissue read");
Luís Henriques 3b4d29
 		ret = bmapping->a_ops->readpage(NULL, backpage);
Luís Henriques 3b4d29
 		if (ret < 0)
Luís Henriques 3b4d29
-			goto unlock_discard;
Luís Henriques 3b4d29
+			goto discard;
Luís Henriques 3b4d29
 	}
Luís Henriques 3b4d29
 
Luís Henriques 3b4d29
 	/* but the page may have been read before the monitor was installed, so
Luís Henriques 3b4d29
@@ -138,6 +138,7 @@ static int cachefiles_read_reissue(struct cachefiles_object *object,
Luís Henriques 3b4d29
 
Luís Henriques 3b4d29
 unlock_discard:
Luís Henriques 3b4d29
 	unlock_page(backpage);
Luís Henriques 3b4d29
+discard:
Luís Henriques 3b4d29
 	spin_lock_irq(&object->work_lock);
Luís Henriques 3b4d29
 	list_del(&monitor->op_link);
Luís Henriques 3b4d29
 	spin_unlock_irq(&object->work_lock);
Luís Henriques 3b4d29