netfs, fscache: Prevent Oops in fscache_put_cache()
authorDan Carpenter <dan.carpenter@linaro.org>
Fri, 12 Jan 2024 06:59:41 +0000 (09:59 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 1 Feb 2024 00:19:01 +0000 (16:19 -0800)
commit1c45256e599061021e2c848952e50f406457e448
tree4aab251a266dfb327ba5497faab9b62bbe81868e
parent7a73190ea557e7f26914b0fe04c1f57a96cb771f
netfs, fscache: Prevent Oops in fscache_put_cache()

[ Upstream commit 3be0b3ed1d76c6703b9ee482b55f7e01c369cc68 ]

This function dereferences "cache" and then checks if it's
IS_ERR_OR_NULL().  Check first, then dereference.

Fixes: 9549332df4ed ("fscache: Implement cache registration")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
Signed-off-by: David Howells <dhowells@redhat.com>
Link: https://lore.kernel.org/r/e84bc740-3502-4f16-982a-a40d5676615c@moroto.mountain/
Signed-off-by: Sasha Levin <sashal@kernel.org>
fs/fscache/cache.c