Paulo Alcantara bd6c57
From: Shyam Prasad N <sprasad@microsoft.com>
Paulo Alcantara bd6c57
Date: Tue, 27 Dec 2022 11:29:28 +0000
Paulo Alcantara bd6c57
Subject: [PATCH] cifs: refcount only the selected iface during interface
Paulo Alcantara bd6c57
 update
Paulo Alcantara bd6c57
Git-commit: 7246210ecdd0cda97fa3e3bb15c32c6c2d9a23b5
Paulo Alcantara bd6c57
References: git-fixes
Paulo Alcantara bd6c57
Patch-mainline: v6.2-rc3
Paulo Alcantara bd6c57
Paulo Alcantara bd6c57
When the server interface for a channel is not active anymore,
Paulo Alcantara bd6c57
we have the logic to select an alternative interface. However
Paulo Alcantara bd6c57
this was not breaking out of the loop as soon as a new alternative
Paulo Alcantara bd6c57
was found. As a result, some interfaces may get refcounted unintentionally.
Paulo Alcantara bd6c57
Paulo Alcantara bd6c57
There was also a bug in checking if we found an alternate iface.
Paulo Alcantara bd6c57
Fixed that too.
Paulo Alcantara bd6c57
Paulo Alcantara bd6c57
Fixes: b54034a73baf ("cifs: during reconnect, update interface if necessary")
Paulo Alcantara bd6c57
Cc: stable@vger.kernel.org # 5.19+
Paulo Alcantara bd6c57
Signed-off-by: Shyam Prasad N <sprasad@microsoft.com>
Paulo Alcantara bd6c57
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>
Paulo Alcantara bd6c57
Signed-off-by: Steve French <stfrench@microsoft.com>
Paulo Alcantara bd6c57
Acked-by: Paulo Alcantara <palcantara@suse.de>
Paulo Alcantara bd6c57
---
Paulo Alcantara bd6c57
 fs/cifs/sess.c | 3 ++-
Paulo Alcantara bd6c57
 1 file changed, 2 insertions(+), 1 deletion(-)
Paulo Alcantara bd6c57
Paulo Alcantara bd6c57
diff --git a/fs/cifs/sess.c b/fs/cifs/sess.c
Paulo Alcantara bd6c57
index 9e7d9f0baa18..0b842a07e157 100644
Paulo Alcantara bd6c57
--- a/fs/cifs/sess.c
Paulo Alcantara bd6c57
+++ b/fs/cifs/sess.c
Paulo Alcantara bd6c57
@@ -292,9 +292,10 @@ cifs_chan_update_iface(struct cifs_ses *ses, struct TCP_Server_Info *server)
Paulo Alcantara bd6c57
 			continue;
Paulo Alcantara bd6c57
 		}
Paulo Alcantara bd6c57
 		kref_get(&iface->refcount);
Paulo Alcantara bd6c57
+		break;
Paulo Alcantara bd6c57
 	}
Paulo Alcantara bd6c57
 
Paulo Alcantara bd6c57
-	if (!list_entry_is_head(iface, &ses->iface_list, iface_head)) {
Paulo Alcantara bd6c57
+	if (list_entry_is_head(iface, &ses->iface_list, iface_head)) {
Paulo Alcantara bd6c57
 		rc = 1;
Paulo Alcantara bd6c57
 		iface = NULL;
Paulo Alcantara bd6c57
 		cifs_dbg(FYI, "unable to find a suitable iface\n");
Paulo Alcantara bd6c57
-- 
Paulo Alcantara bd6c57
2.39.0
Paulo Alcantara bd6c57
Paulo Alcantara bd6c57