]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
cifs: fix leak of iface for primary channel
authorShyam Prasad N <sprasad@microsoft.com>
Tue, 14 Nov 2023 04:54:12 +0000 (04:54 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 3 Dec 2023 06:32:09 +0000 (07:32 +0100)
[ Upstream commit 29954d5b1e0d67a4cd61c30c2201030c97e94b1e ]

My last change in this area introduced a change which
accounted for primary channel in the interface ref count.
However, it did not reduce this ref count on deallocation
of the primary channel. i.e. during umount.

Fixing this leak here, by dropping this ref count for
primary channel while freeing up the session.

Fixes: fa1d0508bdd4 ("cifs: account for primary channel in the interface list")
Cc: stable@vger.kernel.org
Reported-by: Paulo Alcantara <pc@manguebit.com>
Signed-off-by: Shyam Prasad N <sprasad@microsoft.com>
Signed-off-by: Steve French <stfrench@microsoft.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
fs/smb/client/connect.c

index 6ca1e00b3f76ab0b7a9f575b32e04efd28c3869b..5b19918938346fdf73b79c556ab41a5a3d47ee8a 100644 (file)
@@ -2070,6 +2070,12 @@ void cifs_put_smb_ses(struct cifs_ses *ses)
                }
        }
 
+       /* we now account for primary channel in iface->refcount */
+       if (ses->chans[0].iface) {
+               kref_put(&ses->chans[0].iface->refcount, release_iface);
+               ses->chans[0].server = NULL;
+       }
+
        sesInfoFree(ses);
        cifs_put_tcp_session(server, 0);
 }