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)
committerSteve French <stfrench@microsoft.com>
Tue, 14 Nov 2023 17:38:00 +0000 (11:38 -0600)
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>
fs/smb/client/connect.c

index 57c2a7df34578370a046822a9e7844a87b2af8e4..f896f60c924bfa462e8fa764fdf806bcd67b0cfb 100644 (file)
@@ -2065,6 +2065,12 @@ void __cifs_put_smb_ses(struct cifs_ses *ses)
                ses->chans[i].server = NULL;
        }
 
+       /* 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);
 }