From nobody Wed Apr 1 12:56:38 2026 Received: from mail114-241.sinamail.sina.com.cn (mail114-241.sinamail.sina.com.cn [218.30.114.241]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5518E36C5A1 for ; Tue, 31 Mar 2026 07:01:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=218.30.114.241 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774940475; cv=none; b=cAkXXbTqJYfW2hDyMtk8ng2SHGqfbEFBvJDSjWYxhysS7dI/JjrqFE64YbCVnELj2Miu2d/vA6xk9eeiqqGk5YC9taspVL/Lug5yb+5e5/VAXyothDkTKALmSkMq8LPyprFyJV0uL7Bu48ePDFAsfsvlqYcION7LJYLL0Ig/JvM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774940475; c=relaxed/simple; bh=M2wmi5yj3XHFFZnhpaczCRACrgVAh2vHUkmt62Gxaio=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=mIw/sOujsSKreDEKUu3CPtmHOWtBshmf3UacPR+KWJp8xxssY/dI2F5gMg/c0d3ZbHwUkPv8xRetu5CwbOzkBkvK1EFhXEt3KaGNgaqi5k8ESrYyJRt2uNm8p9MdDYoiPXfkCj+cFy1iUwGeesk5oZvk2pBngqg+qyB4NM+etG8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=sina.com; spf=pass smtp.mailfrom=sina.com; dkim=pass (1024-bit key) header.d=sina.com header.i=@sina.com header.b=vibnZAXy; arc=none smtp.client-ip=218.30.114.241 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=sina.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=sina.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=sina.com header.i=@sina.com header.b="vibnZAXy" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sina.com; s=201208; t=1774940470; bh=hZRTzXeo+f/qimGJsHFx65MwoVYeDkem54Ryrk9NRqA=; h=From:Subject:Date:Message-Id; b=vibnZAXyCa907lMwYgzWj13I4FBMp3JCJdXDlOONFzjdHfBP1fGmUMJZNalS3fEj+ 57rslgw1iv1iJeOnfywKJ8h9ZLDnCSS0kSG5IAit3ssqLzAFW568UF6XnavJQJRusy 1JnD/a2aL8ZG2/bQAYMyLTGDRPO5EbrwE89Gep+4= X-SMAIL-HELO: pek-lpg-core6.wrs.com Received: from unknown (HELO pek-lpg-core6.wrs.com)([60.247.85.88]) by sina.com (10.185.250.23) with ESMTP id 69CB712A000051F4; Tue, 31 Mar 2026 15:01:00 +0800 (CST) X-Sender: johnny_haocn@sina.com X-Auth-ID: johnny_haocn@sina.com Authentication-Results: sina.com; spf=none smtp.mailfrom=johnny_haocn@sina.com; dkim=none header.i=none; dmarc=none action=none header.from=johnny_haocn@sina.com X-SMAIL-MID: 9622848913361 X-SMAIL-UIID: C006AE8DB9B74ED79438E91759121FC9-20260331-150100-1 From: Johnny Hao To: gregkh@linuxfoundation.org, stable@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Shuhao Fu , Steve French , Johnny Hao Subject: [PATCH 5.15.y] smb: client: Fix refcount leak for cifs_sb_tlink Date: Tue, 31 Mar 2026 15:00:54 +0800 Message-Id: <20260331070054.4148997-1-johnny_haocn@sina.com> X-Mailer: git-send-email 2.34.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Shuhao Fu [ Upstream commit c2b77f42205ef485a647f62082c442c1cd69d3fc ] Fix three refcount inconsistency issues related to `cifs_sb_tlink`. Comments for `cifs_sb_tlink` state that `cifs_put_tlink()` needs to be called after successful calls to `cifs_sb_tlink()`. Three calls fail to update refcount accordingly, leading to possible resource leaks. Fixes: 8ceb98437946 ("CIFS: Move rename to ops struct") Fixes: 2f1afe25997f ("cifs: Use smb 2 - 3 and cifsacl mount options getacl = functions") Fixes: 366ed846df60 ("cifs: Use smb 2 - 3 and cifsacl mount options setacl = function") Cc: stable@vger.kernel.org Signed-off-by: Shuhao Fu Signed-off-by: Steve French Signed-off-by: Johnny Hao --- fs/cifs/inode.c | 6 ++++-- fs/cifs/smb2ops.c | 8 ++++---- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/fs/cifs/inode.c b/fs/cifs/inode.c index 30a9a89c141b..bb0b172c5a74 100644 --- a/fs/cifs/inode.c +++ b/fs/cifs/inode.c @@ -2023,8 +2023,10 @@ cifs_do_rename(const unsigned int xid, struct dentry= *from_dentry, tcon =3D tlink_tcon(tlink); server =3D tcon->ses->server; =20 - if (!server->ops->rename) - return -ENOSYS; + if (!server->ops->rename) { + rc =3D -ENOSYS; + goto do_rename_exit; + } =20 /* try path-based rename first */ rc =3D server->ops->rename(xid, tcon, from_path, to_path, cifs_sb); diff --git a/fs/cifs/smb2ops.c b/fs/cifs/smb2ops.c index 619905fc694e..0a62720590da 100644 --- a/fs/cifs/smb2ops.c +++ b/fs/cifs/smb2ops.c @@ -3437,8 +3437,7 @@ get_smb2_acl_by_path(struct cifs_sb_info *cifs_sb, utf16_path =3D cifs_convert_path_to_utf16(path, cifs_sb); if (!utf16_path) { rc =3D -ENOMEM; - free_xid(xid); - return ERR_PTR(rc); + goto put_tlink; } =20 oparms.tcon =3D tcon; @@ -3466,6 +3465,7 @@ get_smb2_acl_by_path(struct cifs_sb_info *cifs_sb, SMB2_close(xid, tcon, fid.persistent_fid, fid.volatile_fid); } =20 +put_tlink: cifs_put_tlink(tlink); free_xid(xid); =20 @@ -3506,8 +3506,7 @@ set_smb2_acl(struct cifs_ntsd *pnntsd, __u32 acllen, utf16_path =3D cifs_convert_path_to_utf16(path, cifs_sb); if (!utf16_path) { rc =3D -ENOMEM; - free_xid(xid); - return rc; + goto put_tlink; } =20 oparms.tcon =3D tcon; @@ -3527,6 +3526,7 @@ set_smb2_acl(struct cifs_ntsd *pnntsd, __u32 acllen, SMB2_close(xid, tcon, fid.persistent_fid, fid.volatile_fid); } =20 +put_tlink: cifs_put_tlink(tlink); free_xid(xid); return rc; --=20 2.34.1