smb: client: introduce close_cached_dir_locked()
authorHenrique Carvalho <henrique.carvalho@suse.com>
Thu, 13 Nov 2025 18:09:13 +0000 (15:09 -0300)
committerSteve French <stfrench@microsoft.com>
Thu, 20 Nov 2025 09:03:30 +0000 (03:03 -0600)
commita9d1f38df7ecd0e21233447c9cc6fa1799eddaf3
treee6c35c5fcdabe1a5a3abadad30723d0ceb3da977
parent6a23ae0a96a600d1d12557add110e0bb6e32730c
smb: client: introduce close_cached_dir_locked()

Replace close_cached_dir() calls under cfid_list_lock with a new
close_cached_dir_locked() variant that uses kref_put() instead of
kref_put_lock() to avoid recursive locking when dropping references.

While the existing code works if the refcount >= 2 invariant holds,
this area has proven error-prone. Make deadlocks impossible and WARN
on invariant violations.

Cc: stable@vger.kernel.org
Reviewed-by: David Howells <dhowells@redhat.com>
Signed-off-by: Henrique Carvalho <henrique.carvalho@suse.com>
Signed-off-by: Steve French <stfrench@microsoft.com>
fs/smb/client/cached_dir.c