Skip to contentSkip to conversation

fscache: Fix error handling in fscache_begin_operation()

PATCH Applied David Howells 3 participants 3 messages Mar 15, 2024 – Mar 18, 2024

Subsystems (2)
lore
Share & tools
lore

David Howells

author maintainer
#0 lore raw

PATCH 1/1 fscache: Fix error handling in fscache_begin_operation()

Fix fscache_begin_operation() to clear cres->cache_priv on error, otherwise fscache_resources_valid() will report it as being valid.

---
 fs/netfs/fscache_io.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
fs/netfs/fscache_io.c +3 -1
index ad57e4412c6d..cfd58ad95e7c 100644
@@ -83,8 +83,10 @@ static int fscache_begin_operation(struct netfs_cache_resources *cres,
 	cres->debug_id		= cookie->debug_id;
 	cres->inval_counter	= cookie->inval_counter;
 
-	if (!fscache_begin_cookie_access(cookie, why))
+	if (!fscache_begin_cookie_access(cookie, why)) {
+		cres->cache_priv = NULL;
 		return -ENOBUFS;
+	}
 
 again:
 	spin_lock(&cookie->lock);
Reviewed-by on v1 1/1
#1 lore raw
Quoted 21 lines · David Howells

Fix fscache_begin_operation() to clear cres->cache_priv on error, otherwise fscache_resources_valid() will report it as being valid.

---
 fs/netfs/fscache_io.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
fs/netfs/fscache_io.c +0 -0
index ad57e4412c6d..cfd58ad95e7c 100644
@@ -83,8 +83,10 @@ static int fscache_begin_operation(struct netfs_cache_resources *cres,
 	cres->debug_id		= cookie->debug_id;

fs/netfs/fscache_io.c static int fscache_begin_operation(struct netfs_cache_resources *cres, · line 92

Quoted 10 lines
fs/netfs/fscache_io.c +3 -1
 	cres->inval_counter	= cookie->inval_counter;
 
-	if (!fscache_begin_cookie_access(cookie, why))
+	if (!fscache_begin_cookie_access(cookie, why)) {
+		cres->cache_priv = NULL;
 		return -ENOBUFS;
+	}
 
 again:
 	spin_lock(&cookie->lock);
maintainer Applied
#2 lore raw
In reply to David Howells
Quoted 5 lines · David Howells

Fix fscache_begin_operation() to clear cres->cache_priv on error, otherwise fscache_resources_valid() will report it as being valid.

Applied to the vfs.fixes branch of the vfs/vfs.git tree. Patches in the vfs.fixes branch should appear in linux-next soon.

Please report any outstanding bugs that were missed during review in a new review to the original patch series allowing us to drop it.

It's encouraged to provide Acked-bys and Reviewed-bys even though the patch has now been applied. If possible patch trailers will be updated.

Note that commit hashes shown below are subject to change due to rebase, trailer updates or similar. If in doubt, please check the listed branch.

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs.git
branch: vfs.fixes

[1/1] fscache: Fix error handling in fscache_begin_operation()

      https://git.kernel.org/vfs/vfs/c/d86f1160d819