]> git.baikalelectronics.ru Git - kernel.git/commit
fscache: don't leak cookie access refs if invalidation is in progress or failed
authorJeff Layton <jlayton@kernel.org>
Fri, 5 Aug 2022 10:42:45 +0000 (06:42 -0400)
committerDavid Howells <dhowells@redhat.com>
Tue, 9 Aug 2022 13:13:55 +0000 (14:13 +0100)
commit65b6a4cd3259db0c925538ebd44c65c1863429f5
treeca92f6258605d877ac7155f86ca95d1e0499f3cd
parent2cd08cb75e50502e452883eb9efa13dc8c4348e8
fscache: don't leak cookie access refs if invalidation is in progress or failed

It's possible for a request to invalidate a fscache_cookie will come in
while we're already processing an invalidation. If that happens we
currently take an extra access reference that will leak. Only call
__fscache_begin_cookie_access if the FSCACHE_COOKIE_DO_INVALIDATE bit
was previously clear.

Also, ensure that we attempt to clear the bit when the cookie is
"FAILED" and put the reference to avoid an access leak.

Fixes: ad2cfc102e5e ("fscache: Fix invalidation/lookup race")
Suggested-by: David Howells <dhowells@redhat.com>
Signed-off-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: David Howells <dhowells@redhat.com>
fs/fscache/cookie.c