Return-Path: Received: from mail-co1nam03on0127.outbound.protection.outlook.com ([104.47.40.127]:41117 "EHLO NAM03-CO1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1032379AbeCAPeD (ORCPT ); Thu, 1 Mar 2018 10:34:03 -0500 From: Sasha Levin To: "stable@vger.kernel.org" , "stable-commits@vger.kernel.org" CC: Matthew Wilcox , Steve French , Sasha Levin Subject: [added to the 4.1 stable tree] cifs: Fix missing put_xid in cifs_file_strict_mmap Date: Thu, 1 Mar 2018 15:25:56 +0000 Message-ID: <20180301152116.1486-316-alexander.levin@microsoft.com> References: <20180301152116.1486-1-alexander.levin@microsoft.com> In-Reply-To: <20180301152116.1486-1-alexander.levin@microsoft.com> Content-Language: en-US Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org List-ID: From: Matthew Wilcox This patch has been added to the 4.1 stable tree. If you have any objections, please let us know. =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D [ Upstream commit f04a703c3d613845ae3141bfaf223489de8ab3eb ] If cifs_zap_mapping() returned an error, we would return without putting the xid that we got earlier. Restructure cifs_file_strict_mmap() and cifs_file_mmap() to be more similar to each other and have a single point of return that always puts the xid. Signed-off-by: Matthew Wilcox Signed-off-by: Steve French CC: Stable Signed-off-by: Sasha Levin --- fs/cifs/file.c | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/fs/cifs/file.c b/fs/cifs/file.c index 47e04038a846..1366d2151389 100644 --- a/fs/cifs/file.c +++ b/fs/cifs/file.c @@ -3231,20 +3231,18 @@ static struct vm_operations_struct cifs_file_vm_ops= =3D { =20 int cifs_file_strict_mmap(struct file *file, struct vm_area_struct *vma) { - int rc, xid; + int xid, rc =3D 0; struct inode *inode =3D file_inode(file); =20 xid =3D get_xid(); =20 - if (!CIFS_CACHE_READ(CIFS_I(inode))) { + if (!CIFS_CACHE_READ(CIFS_I(inode))) rc =3D cifs_zap_mapping(inode); - if (rc) - return rc; - } - - rc =3D generic_file_mmap(file, vma); - if (rc =3D=3D 0) + if (!rc) + rc =3D generic_file_mmap(file, vma); + if (!rc) vma->vm_ops =3D &cifs_file_vm_ops; + free_xid(xid); return rc; } @@ -3254,16 +3252,16 @@ int cifs_file_mmap(struct file *file, struct vm_are= a_struct *vma) int rc, xid; =20 xid =3D get_xid(); + rc =3D cifs_revalidate_file(file); - if (rc) { + if (rc) cifs_dbg(FYI, "Validation prior to mmap failed, error=3D%d\n", rc); - free_xid(xid); - return rc; - } - rc =3D generic_file_mmap(file, vma); - if (rc =3D=3D 0) + if (!rc) + rc =3D generic_file_mmap(file, vma); + if (!rc) vma->vm_ops =3D &cifs_file_vm_ops; + free_xid(xid); return rc; } --=20 2.14.1