cifs: release cached dentries only if mount is complete
authorShyam Prasad N <sprasad@microsoft.com>
Fri, 1 Apr 2022 06:25:17 +0000 (06:25 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 20 Apr 2022 07:34:10 +0000 (09:34 +0200)
commit675e7d3086d0aa360b6ce856ce55cd003589f9ad
treec971357d8918dc2a3b91c3109522464330506bb0
parentd40cf3492277d203c1f676cb9df88ab55d0c5d0f
cifs: release cached dentries only if mount is complete

[ Upstream commit d788e51636462e61c6883f7d96b07b06bc291650 ]

During cifs_kill_sb, we first dput all the dentries that we have cached.
However this function can also get called for mount failures.
So dput the cached dentries only if the filesystem mount is complete.
i.e. cifs_sb->root is populated.

Fixes: 5e9c89d43fa6 ("cifs: Grab a reference for the dentry of the cached directory during the lifetime of the cache")
Signed-off-by: Shyam Prasad N <sprasad@microsoft.com>
Reviewed-by: Ronnie Sahlberg <lsahlber@redhat.com>
Signed-off-by: Steve French <stfrench@microsoft.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
fs/cifs/cifsfs.c