linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jeff Layton <jlayton@poochiereds.net>
To: Steve French <smfrench@gmail.com>
Cc: linux-cifs@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 3/4] [SMB3] Fix dereference before null check warning
Date: Tue, 31 Mar 2015 20:46:34 -0400	[thread overview]
Message-ID: <20150331204634.4d38c27e@synchrony.poochiereds.net> (raw)
In-Reply-To: <1427434082-4299-4-git-send-email-smfrench@gmail.com>

On Fri, 27 Mar 2015 00:28:01 -0500
Steve French <smfrench@gmail.com> wrote:

> null tcon is not likely in these paths in current
> code, but obviously it does clarify the code to
> check for null (if at all) before derefrencing
> rather than after.
> 
> Reported by Coverity (CID 1042666)
> 
> Signed-off-by: Steve French <smfrench@gmail.com>

I don't get it. Under what circumstances would the tcon ever be NULL
here? If there aren't any then this is just confusing. It would be
better to just remove the bogus checks for a NULL tcon instead.

> ---
>  fs/cifs/smb2pdu.c | 13 ++++++++-----
>  1 file changed, 8 insertions(+), 5 deletions(-)
> 
> diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c
> index 1b906de..78b329f 100644
> --- a/fs/cifs/smb2pdu.c
> +++ b/fs/cifs/smb2pdu.c
> @@ -1218,7 +1218,7 @@ SMB2_ioctl(const unsigned int xid, struct cifs_tcon *tcon, u64 persistent_fid,
>  	struct smb2_ioctl_req *req;
>  	struct smb2_ioctl_rsp *rsp;
>  	struct TCP_Server_Info *server;
> -	struct cifs_ses *ses = tcon->ses;
> +	struct cifs_ses *ses;
>  	struct kvec iov[2];
>  	int resp_buftype;
>  	int num_iovecs;
> @@ -1233,6 +1233,11 @@ SMB2_ioctl(const unsigned int xid, struct cifs_tcon *tcon, u64 persistent_fid,
>  	if (plen)
>  		*plen = 0;
>  
> +	if (tcon)
> +		ses = tcon->ses;
> +	else
> +		return -EIO;
> +
>  	if (ses && (ses->server))
>  		server = ses->server;
>  	else
> @@ -1296,14 +1301,12 @@ SMB2_ioctl(const unsigned int xid, struct cifs_tcon *tcon, u64 persistent_fid,
>  	rsp = (struct smb2_ioctl_rsp *)iov[0].iov_base;
>  
>  	if ((rc != 0) && (rc != -EINVAL)) {
> -		if (tcon)
> -			cifs_stats_fail_inc(tcon, SMB2_IOCTL_HE);
> +		cifs_stats_fail_inc(tcon, SMB2_IOCTL_HE);
>  		goto ioctl_exit;
>  	} else if (rc == -EINVAL) {
>  		if ((opcode != FSCTL_SRV_COPYCHUNK_WRITE) &&
>  		    (opcode != FSCTL_SRV_COPYCHUNK)) {
> -			if (tcon)
> -				cifs_stats_fail_inc(tcon, SMB2_IOCTL_HE);
> +			cifs_stats_fail_inc(tcon, SMB2_IOCTL_HE);
>  			goto ioctl_exit;
>  		}
>  	}


-- 
Jeff Layton <jlayton@poochiereds.net>

  parent reply	other threads:[~2015-04-01  0:46 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-27  5:27 [PATCH 0/4] Fix various coverity warnings in fs/cifs Steve French
2015-03-27  5:27 ` [PATCH 1/4] [SMB3] Fix warning on uninitialized buftype Steve French
2015-03-28 14:19   ` Shirish Pargaonkar
2015-03-30  9:36   ` Sachin Prabhu
2015-04-01  0:35   ` Jeff Layton
2015-03-27  5:28 ` [PATCH 2/4] [CIFS] Don't ignore errors on encrypting password in SMBTcon Steve French
2015-03-28 14:26   ` Shirish Pargaonkar
2015-03-30  9:44   ` Sachin Prabhu
2015-04-01  0:37   ` Jeff Layton
2015-03-27  5:28 ` [PATCH 3/4] [SMB3] Fix dereference before null check warning Steve French
2015-03-28 14:27   ` Shirish Pargaonkar
2015-03-30  9:50   ` Sachin Prabhu
2015-04-01  0:46   ` Jeff Layton [this message]
2015-04-01  5:00     ` Steve French
2015-04-01 11:07       ` Jeff Layton
2015-03-27  5:28 ` [PATCH 4/4] [SMB3] Fix coverity warning Steve French
2015-03-28 15:05   ` Shirish Pargaonkar
2015-03-30  9:51   ` Sachin Prabhu
2015-04-01  0:38   ` Jeff Layton

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20150331204634.4d38c27e@synchrony.poochiereds.net \
    --to=jlayton@poochiereds.net \
    --cc=linux-cifs@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=smfrench@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).