Received: by 10.223.185.116 with SMTP id b49csp2506162wrg; Thu, 15 Feb 2018 12:40:39 -0800 (PST) X-Google-Smtp-Source: AH8x2263bLMmI4jd3y+OYVbaylTprw2r6vQneepGtkwD9tmQHXNUo32R3JnwiHytUc+LfOeKVHuB X-Received: by 2002:a17:902:4683:: with SMTP id p3-v6mr3649065pld.408.1518727239182; Thu, 15 Feb 2018 12:40:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518727239; cv=none; d=google.com; s=arc-20160816; b=Zpwoomk7lCsto8iIj8i/erltyTaQ+5bwOlBXXZ+rjr1xnDlXjTryT/lB/5ndpfhv5x PSvv8aFzGNFMF4qc5qIOBuj9HxvtzpJpU4KGPG22m4dxhACe7iUnleFmG0fwVJKiZT02 gx/23h02HcLH0XrJcS52GKcpSbhZOwuEekJiqXiwWk2EvU0vFUIkg614NnO0/YnvdJh6 hK9EEbMVqvt9W4tp5z9JQy/x2wVRUbx6Glmgdsdo3j6FZmIERhTwxGZUJnE6rJiLYOwf utxal3g4H5pLUx12HmzucdxvNFHLsIKlUe6N3aeNeUxLoBZr50pGe6/gtx8NzcpTMfZu kn8Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=AV5EAT+15a/FjtzF/IGutP9TVW4mIE0BW/2G8B/Y6l0=; b=WpX9e0C+Lhl4PkjJHbYBi4/9P2gty2soWqykeZ8l6g1x5aha1BY0oxsMZ87KD2fr50 YfVop/7sZnL+Dz6PRHrQ23u7b7HUKUFGHKDMEJWD1RFV2jAFzXJscIBAKEuJAYoOeUc/ LBrroC/P/Lg3dksmTiqHdufY/BhW/XfXnvLpj8aC5f789io7+QwspZmk94iQ2Wz9siL0 0UVXKXD59mWmRzCkL3xdy8PW0xlZ40b7Hnn1U6jz/Fw+Smyn+Z1j9iXpEI9fOXbcp7Az CHIlrcbdOb9Jbc98yWw0aRLd9jeGzFrlx9Ljt1byDW3Wu9Kay5+Nb+yg2Oe6NYG9OKIh L6jA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b10si3345055pgf.613.2018.02.15.12.40.24; Thu, 15 Feb 2018 12:40:39 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1161122AbeBOPSt (ORCPT + 99 others); Thu, 15 Feb 2018 10:18:49 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:47548 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1161063AbeBOPSk (ORCPT ); Thu, 15 Feb 2018 10:18:40 -0500 Received: from localhost (LFbn-1-12258-90.w90-92.abo.wanadoo.fr [90.92.71.90]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 78C3CFEB; Thu, 15 Feb 2018 15:18:39 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Matthew Wilcox , Steve French Subject: [PATCH 3.18 11/45] cifs: Fix missing put_xid in cifs_file_strict_mmap Date: Thu, 15 Feb 2018 16:17:02 +0100 Message-Id: <20180215144118.213061765@linuxfoundation.org> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180215144115.863307741@linuxfoundation.org> References: <20180215144115.863307741@linuxfoundation.org> User-Agent: quilt/0.65 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 3.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Matthew Wilcox commit f04a703c3d613845ae3141bfaf223489de8ab3eb upstream. 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 Signed-off-by: Greg Kroah-Hartman --- fs/cifs/file.c | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) --- a/fs/cifs/file.c +++ b/fs/cifs/file.c @@ -3261,20 +3261,18 @@ static struct vm_operations_struct cifs_ int cifs_file_strict_mmap(struct file *file, struct vm_area_struct *vma) { - int rc, xid; + int xid, rc = 0; struct inode *inode = file_inode(file); xid = get_xid(); - if (!CIFS_CACHE_READ(CIFS_I(inode))) { + if (!CIFS_CACHE_READ(CIFS_I(inode))) rc = cifs_zap_mapping(inode); - if (rc) - return rc; - } - - rc = generic_file_mmap(file, vma); - if (rc == 0) + if (!rc) + rc = generic_file_mmap(file, vma); + if (!rc) vma->vm_ops = &cifs_file_vm_ops; + free_xid(xid); return rc; } @@ -3284,16 +3282,16 @@ int cifs_file_mmap(struct file *file, st int rc, xid; xid = get_xid(); + rc = cifs_revalidate_file(file); - if (rc) { + if (rc) cifs_dbg(FYI, "Validation prior to mmap failed, error=%d\n", rc); - free_xid(xid); - return rc; - } - rc = generic_file_mmap(file, vma); - if (rc == 0) + if (!rc) + rc = generic_file_mmap(file, vma); + if (!rc) vma->vm_ops = &cifs_file_vm_ops; + free_xid(xid); return rc; }