Skip to content

Commit 3be0b3e

Browse files
Dan Carpenterdhowells
authored andcommitted
netfs, fscache: Prevent Oops in fscache_put_cache()
This function dereferences "cache" and then checks if it's IS_ERR_OR_NULL(). Check first, then dereference. Fixes: 9549332 ("fscache: Implement cache registration") Signed-off-by: Dan Carpenter <[email protected]> Signed-off-by: David Howells <[email protected]> Link: https://lore.kernel.org/r/[email protected]/ # v2
1 parent c40497d commit 3be0b3e

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

fs/netfs/fscache_cache.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,13 +179,14 @@ EXPORT_SYMBOL(fscache_acquire_cache);
179179
void fscache_put_cache(struct fscache_cache *cache,
180180
enum fscache_cache_trace where)
181181
{
182-
unsigned int debug_id = cache->debug_id;
182+
unsigned int debug_id;
183183
bool zero;
184184
int ref;
185185

186186
if (IS_ERR_OR_NULL(cache))
187187
return;
188188

189+
debug_id = cache->debug_id;
189190
zero = __refcount_dec_and_test(&cache->ref, &ref);
190191
trace_fscache_cache(debug_id, ref - 1, where);
191192

0 commit comments

Comments
 (0)