cifs: reconnect work should have reference on server struct
authorShyam Prasad N <sprasad@microsoft.com>
Fri, 13 Oct 2023 11:43:09 +0000 (11:43 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 1 Feb 2024 00:18:48 +0000 (16:18 -0800)
commit173ddac64b472e9f4de827a30ecfdc66a4d39604
tree55fdfad4a0a6359733504e04e36e8f0b6a2106bd
parentc395f798a7f2ef3374a637bafac28af983eb0497
cifs: reconnect work should have reference on server struct

[ Upstream commit 19a4b9d6c372cab6a3b2c9a061a236136fe95274 ]

The delayed work for reconnect takes server struct
as a parameter. But it does so without holding a ref
to it. Normally, this may not show a problem as
the reconnect work is only cancelled on umount.

However, since we now plan to support scaling down of
channels, and the scale down can happen from reconnect
work itself, we need to fix it.

This change takes a reference on the server struct
before it is passed to the delayed work. And drops
the reference in the delayed work itself. Or if
the delayed work is successfully cancelled, by the
process that cancels it.

Signed-off-by: Shyam Prasad N <sprasad@microsoft.com>
Signed-off-by: Steve French <stfrench@microsoft.com>
Stable-dep-of: 78e727e58e54 ("cifs: update iface_last_update on each query-and-update")
Signed-off-by: Sasha Levin <sashal@kernel.org>
fs/smb/client/connect.c
fs/smb/client/smb2pdu.c