From patchwork Tue Nov 2 20:22:50 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 298082 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id oA2KN0m1032385 for ; Tue, 2 Nov 2010 20:23:01 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752785Ab0KBUW4 (ORCPT ); Tue, 2 Nov 2010 16:22:56 -0400 Received: from mx1.redhat.com ([209.132.183.28]:43576 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752698Ab0KBUW4 (ORCPT ); Tue, 2 Nov 2010 16:22:56 -0400 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id oA2KMrls022111 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 2 Nov 2010 16:22:53 -0400 Received: from tlielax.poochiereds.net (vpn-8-111.rdu.redhat.com [10.11.8.111]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id oA2KMqGf003357; Tue, 2 Nov 2010 16:22:52 -0400 Date: Tue, 2 Nov 2010 16:22:50 -0400 From: Jeff Layton To: Dan Carpenter Cc: Steve French , linux-cifs@vger.kernel.org, samba-technical@lists.samba.org, kernel-janitors@vger.kernel.org Subject: Re: [patch 2/2] cifs: dereferencing first then checking Message-ID: <20101102162250.3a2aa670@tlielax.poochiereds.net> In-Reply-To: <20101028034434.GR6062@bicker> References: <20101027212253.GL6062@bicker> <20101027195123.0a712a53@tlielax.poochiereds.net> <20101028034434.GR6062@bicker> Mime-Version: 1.0 X-Scanned-By: MIMEDefang 2.67 on 10.5.11.11 Sender: linux-cifs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-cifs@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter1.kernel.org [140.211.167.41]); Tue, 02 Nov 2010 20:23:01 +0000 (UTC) diff --git a/fs/cifs/file.c b/fs/cifs/file.c index a566f15..a59b53f 100644 --- a/fs/cifs/file.c +++ b/fs/cifs/file.c @@ -755,12 +755,6 @@ int cifs_lock(struct file *file, int cmd, struct file_lock *pfLock) cifs_sb = CIFS_SB(file->f_path.dentry->d_sb); tcon = tlink_tcon(((struct cifsFileInfo *)file->private_data)->tlink); - - if (file->private_data == NULL) { - rc = -EBADF; - FreeXid(xid); - return rc; - } netfid = ((struct cifsFileInfo *)file->private_data)->netfid; if ((tcon->ses->capabilities & CAP_UNIX) && @@ -1155,7 +1149,7 @@ struct cifsFileInfo *find_writable_file(struct cifsInodeInfo *cifs_inode, bool fsuid_only) { struct cifsFileInfo *open_file; - struct cifs_sb_info *cifs_sb = CIFS_SB(cifs_inode->vfs_inode.i_sb); + struct cifs_sb_info *cifs_sb; bool any_available = false; int rc; @@ -1169,6 +1163,8 @@ struct cifsFileInfo *find_writable_file(struct cifsInodeInfo *cifs_inode, return NULL; } + cifs_sb = CIFS_SB(cifs_inode->vfs_inode.i_sb); + /* only filter by fsuid on multiuser mounts */ if (!(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MULTIUSER)) fsuid_only = false;