From patchwork Fri Dec 15 20:48:32 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Matthew Wilcox (Oracle)" X-Patchwork-Id: 10116009 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 9B9D16019C for ; Fri, 15 Dec 2017 20:48:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8D9072A177 for ; Fri, 15 Dec 2017 20:48:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 811102A179; Fri, 15 Dec 2017 20:48:47 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0E51E2A177 for ; Fri, 15 Dec 2017 20:48:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756125AbdLOUsq (ORCPT ); Fri, 15 Dec 2017 15:48:46 -0500 Received: from bombadil.infradead.org ([65.50.211.133]:44152 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755864AbdLOUsq (ORCPT ); Fri, 15 Dec 2017 15:48:46 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Message-Id:Date:Subject:Cc:To:From: Sender:Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=ph3sgu2EBOFaO10FxjzlfBUaJ5O43JjKzLTx6l7v/jc=; b=lBIF4KN1nivpcShF82YZXcLOu KLAJkIvJaAkJfKT1jMl7E5tsCxk6Zs8hFa8I+4d5kwJnlpVbCjj9pX8tXXBfiJW7SjcTqq3F7JpDG GKa7VvCYqAFAhfoBQyDkIKjhsxyjuJCpTa7jH1kGl3b+Blxu4WO75n5gegjLsLmK8mewXOJeiTngT aytdfcF1Xch1DFbPNCycCnQMXnY41wJCcVOOAglyiVhY6I5CZqGziUR3dVs13KfrgZXs8KCoOe7dh nn3QzmVp8XjskIChucb26mvIHDNxmSzIRInUFcbhgwwXnSrUkULK7/y0sahzMWed2vWqdyXdut8FX e5KtIJfsA==; Received: from willy by bombadil.infradead.org with local (Exim 4.87 #1 (Red Hat Linux)) id 1ePwuR-0003MO-BA; Fri, 15 Dec 2017 20:48:43 +0000 From: Matthew Wilcox To: Steve French , linux-cifs@vger.kernel.org Cc: Matthew Wilcox , willy@infradead.org Subject: [PATCH] cifs: Fix missing put_xid in cifs_file_strict_mmap Date: Fri, 15 Dec 2017 12:48:32 -0800 Message-Id: <20171215204832.12764-1-willy@infradead.org> X-Mailer: git-send-email 2.9.5 Sender: linux-cifs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-cifs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Matthew Wilcox 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 --- 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 df9f682708c6..3a85df2a9baf 100644 --- a/fs/cifs/file.c +++ b/fs/cifs/file.c @@ -3471,20 +3471,18 @@ static const struct vm_operations_struct cifs_file_vm_ops = { 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; } @@ -3494,16 +3492,16 @@ int cifs_file_mmap(struct file *file, struct vm_area_struct *vma) 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; }