cifs: refcount only the selected iface during interface update
authorShyam Prasad N <sprasad@microsoft.com>
Tue, 27 Dec 2022 11:29:28 +0000 (11:29 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 12 Jan 2023 11:01:55 +0000 (12:01 +0100)
commit94d0e33c5f5270ff3615ba3d173bf37dfcf1e64a
treeb53fe7773136cd9732dff3b82650e6c7bc6286c3
parent76f1ff02e23edf6e4a346743b13a2287cfe5af06
cifs: refcount only the selected iface during interface update

commit 7246210ecdd0cda97fa3e3bb15c32c6c2d9a23b5 upstream.

When the server interface for a channel is not active anymore,
we have the logic to select an alternative interface. However
this was not breaking out of the loop as soon as a new alternative
was found. As a result, some interfaces may get refcounted unintentionally.

There was also a bug in checking if we found an alternate iface.
Fixed that too.

Fixes: b54034a73baf ("cifs: during reconnect, update interface if necessary")
Cc: stable@vger.kernel.org # 5.19+
Signed-off-by: Shyam Prasad N <sprasad@microsoft.com>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>
Signed-off-by: Steve French <stfrench@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/cifs/sess.c