From: David Howells Date: Fri, 15 Mar 2024 14:48:26 +0000 (+0000) Subject: fscache: Fix error handling in fscache_begin_operation() X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=449ac5514631dd9b9b66dd708dd5beb1428e2812;p=linux.git 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. Signed-off-by: David Howells Link: https://lore.kernel.org/r/3933237.1710514106@warthog.procyon.org.uk Reviewed-by: Jeff Layton Reported-by: Marc Dionne cc: Jeff Layton cc: netfs@lists.linux.dev cc: linux-fsdevel@vger.kernel.org Signed-off-by: Christian Brauner --- diff --git a/fs/netfs/fscache_io.c b/fs/netfs/fscache_io.c index ad572f7ee897b..43a651ed82641 100644 --- a/fs/netfs/fscache_io.c +++ b/fs/netfs/fscache_io.c @@ -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);