Fix various coverity warnings in fs/cifs
Subsystems (2)
cover Fix various coverity warnings in fs/cifs
Four small fixes to address warnings coverity analyzer displays for fs/cifs.
Steve French (4):
[SMB3] Fix warning on uninitialized buftype
[CIFS] Don't ignore errors on encrypting password in SMBTcon [SMB3] Fix dereference before null check warning [SMB3] Fix coverity warning
fs/cifs/connect.c | 6 ++++++ fs/cifs/smb2misc.c | 2 +- fs/cifs/smb2pdu.c | 15 +++++++++------ 3 files changed, 16 insertions(+), 7 deletions(-)
Signature · 1 line
1.9.1
PATCH 1/4 Fix warning on uninitialized buftype
Pointed out by coverity analyzer. resp_buftype is not initialized in one path which can rarely log a spurious warning (buf is null so there will not be a problem with freeing data, but if buf_type were randomly set to wrong value could log a warning)
Reported by Coverity (CID 1269144)
--- fs/cifs/smb2pdu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/cifs/smb2pdu.c +1 -1
@@ -2114,7 +2114,7 @@ SMB2_query_directory(const unsigned int xid, struct cifs_tcon *tcon,struct kvec iov[2 ];int rc =0 ;int len; -int resp_buftype; +int resp_buftype =CIFS_NO_BUFFER ;unsigned char *bufptr;struct TCP_Server_Info *server;struct cifs_ses *ses = tcon->ses;
Signature · 1 line
1.9.1
Re: [PATCH 1/4] [SMB3] Fix warning on uninitialized buftype
Looks correct.
Quoted 33 lines · Steve French
Pointed out by coverity analyzer.
resp_buftypeis not initialized in one path which can rarely log a spurious warning (buf is null so there will not be a problem with freeing data, but ifbuf_typewere randomly set to wrong value could log a warning)Reported by Coverity (CID 1269144)
Signed-off-by Steve French <[email protected]>--- fs/cifs/smb2pdu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)fs/cifs/smb2pdu.c +1
-2@@ -2114,7 +2114,7 @@ SMB2_query_directory(const unsigned int xid, struct cifs_tcon *tcon,struct kvec iov[2 ];int rc =0 ;int len; -int resp_buftype; +int resp_buftype =CIFS_NO_BUFFER ;unsigned char *bufptr;struct TCP_Server_Info *server;struct cifs_ses *ses = tcon->ses; --1.9.1
--
To unsubscribe from this list: send the line "unsubscribe linux-cifs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 1/4] [SMB3] Fix warning on uninitialized buftype
In reply to Steve FrenchQuoted 9 lines · Steve French
Pointed out by coverity analyzer.
resp_buftypeis not initialized in one path which can rarely log a spurious warning (buf is null so there will not be a problem with freeing data, but ifbuf_typewere randomly set to wrong value could log a warning)Reported by Coverity (CID 1269144)
Signed-off-by Steve French <[email protected]>
Quoted 17 lines
--- fs/cifs/smb2pdu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)fs/cifs/smb2pdu.c +1
-1@@ -2114,7 +2114,7 @@ SMB2_query_directory(const unsigned int xid, struct cifs_tcon *tcon,struct kvec iov[2 ];int rc =0 ;int len; -int resp_buftype; +int resp_buftype =CIFS_NO_BUFFER ;unsigned char *bufptr;struct TCP_Server_Info *server;struct cifs_ses *ses = tcon->ses;
Re: [PATCH 1/4] [SMB3] Fix warning on uninitialized buftype
In reply to Steve FrenchQuoted 18 lines · On Fri, 27 Mar 2015 00:27:59 -0500 Steve French <[email protected]> wrote:
Pointed out by coverity analyzer.
resp_buftypeis not initialized in one path which can rarely log a spurious warning (buf is null so there will not be a problem with freeing data, but ifbuf_typewere randomly set to wrong value could log a warning)Reported by Coverity (CID 1269144)
Signed-off-by Steve French <[email protected]>--- fs/cifs/smb2pdu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)fs/cifs/smb2pdu.c +0
-0
fs/cifs/smb2pdu.c SMB2_query_directory(const unsigned int xid, struct cifs_tcon *tcon, · line 2120
Quoted 8 lines
fs/cifs/smb2pdu.c +1
-1@@ -2114,7 +2114,7 @@ SMB2_query_directory(const unsigned int xid, struct cifs_tcon *tcon,struct kvec iov[2 ];int rc =0 ;int len; -int resp_buftype; +int resp_buftype =CIFS_NO_BUFFER ;unsigned char *bufptr;struct TCP_Server_Info *server;struct cifs_ses *ses = tcon->ses;
PATCH 2/4 Don't ignore errors on encrypting password in SMBTcon
In reply to Steve FrenchAlthough unlikely to fail (and tree connect does not commonly send a password since SECMODE_USER is the default for most servers) do not ignore errors on SMBNTEncrypt in SMB Tree Connect.
Reported by Coverity (CID 1226853)
--- fs/cifs/connect.c | 6 ++++++ 1 file changed, 6 insertions(+)
fs/cifs/connect.c +6 -0
@@ -3696,6 +3696,12 @@ CIFSTCon(const unsigned int xid, struct cifs_ses *ses,#endif /* CIFS_WEAK_PW_HASH */ rc =SMBNTencrypt (tcon->password, ses->server->cryptkey, bcc_ptr, nls_codepage); +if (rc) { +cifs_dbg (FYI ,"%s Can't generate NTLM rsp. Error: %d\n" , + __func__, rc); +cifs_buf_release (smb_buffer); +return rc; + } bcc_ptr +=CIFS_AUTH_RESP_SIZE ;if (ses->capabilities &CAP_UNICODE ) {
Signature · 1 line
1.9.1
Re: [PATCH 2/4] [CIFS] Don't ignore errors on encrypting password in SMBTcon
Looks correct, although we could just goto a label at the end of this function which
does the same.
Quoted 35 lines · Steve French
Although unlikely to fail (and tree connect does not commonly send a password since
SECMODE_USERis the default for most servers) do not ignore errors on SMBNTEncrypt in SMB Tree Connect.Reported by Coverity (CID 1226853)
Signed-off-by Steve French <[email protected]>--- fs/cifs/connect.c | 6 ++++++ 1 file changed, 6 insertions(+)fs/cifs/connect.c +6
-1@@ -3696,6 +3696,12 @@ CIFSTCon(const unsigned int xid, struct cifs_ses *ses,#endif /* CIFS_WEAK_PW_HASH */ rc =SMBNTencrypt (tcon->password, ses->server->cryptkey, bcc_ptr, nls_codepage); +if (rc) { +cifs_dbg (FYI ,"%s Can't generate NTLM rsp. Error: %d\n" , + __func__, rc); +cifs_buf_release (smb_buffer); +return rc; + } bcc_ptr +=CIFS_AUTH_RESP_SIZE ;if (ses->capabilities &CAP_UNICODE ) { --1.9.1
--
To unsubscribe from this list: send the line "unsubscribe linux-cifs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 2/4] [CIFS] Don't ignore errors on encrypting password in SMBTcon
In reply to Steve FrenchQuoted 7 lines · Steve French
Although unlikely to fail (and tree connect does not commonly send a password since
SECMODE_USERis the default for most servers) do not ignore errors on SMBNTEncrypt in SMB Tree Connect.Reported by Coverity (CID 1226853)
Signed-off-by Steve French <[email protected]>
Quoted 21 lines
--- fs/cifs/connect.c | 6 ++++++ 1 file changed, 6 insertions(+)fs/cifs/connect.c +6
-0@@ -3696,6 +3696,12 @@ CIFSTCon(const unsigned int xid, struct cifs_ses *ses,#endif /* CIFS_WEAK_PW_HASH */ rc =SMBNTencrypt (tcon->password, ses->server->cryptkey, bcc_ptr, nls_codepage); +if (rc) { +cifs_dbg (FYI ,"%s Can't generate NTLM rsp. Error: %d\n" , + __func__, rc); +cifs_buf_release (smb_buffer); +return rc; + } bcc_ptr +=CIFS_AUTH_RESP_SIZE ;if (ses->capabilities &CAP_UNICODE ) {
Re: [PATCH 2/4] [CIFS] Don't ignore errors on encrypting password in SMBTcon
In reply to Steve FrenchQuoted 18 lines · On Fri, 27 Mar 2015 00:28:00 -0500 Steve French…
Although unlikely to fail (and tree connect does not commonly send a password since
SECMODE_USERis the default for most servers) do not ignore errors on SMBNTEncrypt in SMB Tree Connect.Reported by Coverity (CID 1226853)
Signed-off-by Steve French <[email protected]>--- fs/cifs/connect.c | 6 ++++++ 1 file changed, 6 insertions(+)fs/cifs/connect.c +0
-0@@ -3696,6 +3696,12 @@ CIFSTCon(const unsigned int xid, struct cifs_ses *ses,#endif /* CIFS_WEAK_PW_HASH */ rc = SMBNTencrypt(tcon->password, ses->server->cryptkey,
fs/cifs/connect.c CIFSTCon(const unsigned int xid, struct cifs_ses *ses, · line 3707
Quoted 10 lines
fs/cifs/connect.c +6
-0bcc_ptr, nls_codepage); +if (rc) { +cifs_dbg (FYI ,"%s Can't generate NTLM rsp. Error: %d\n" , + __func__, rc); +cifs_buf_release (smb_buffer); +return rc; + } bcc_ptr +=CIFS_AUTH_RESP_SIZE ;if (ses->capabilities &CAP_UNICODE ) {
Acked-by:
Signature · 1 line
Jeff Layton <[email protected]>
PATCH 3/4 Fix dereference before null check warning
In reply to Steve Frenchnull 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)
--- fs/cifs/smb2pdu.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-)
fs/cifs/smb2pdu.c +8 -5
@@ -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; } }
Signature · 1 line
1.9.1
Re: [PATCH 3/4] [SMB3] Fix dereference before null check warning
Looks correct.
Quoted 61 lines · Steve French
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 <[email protected]>--- fs/cifs/smb2pdu.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-)fs/cifs/smb2pdu.c +8
-6@@ -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; } } --1.9.1
--
To unsubscribe from this list: send the line "unsubscribe linux-cifs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 3/4] [SMB3] Fix dereference before null check warning
In reply to Steve FrenchQuoted 8 lines · Steve French
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 <[email protected]>
Quoted 46 lines
--- fs/cifs/smb2pdu.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-)fs/cifs/smb2pdu.c +8
-5@@ -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; } }
Re: [PATCH 3/4] [SMB3] Fix dereference before null check warning
In reply to Steve FrenchQuoted 8 lines · On Fri, 27 Mar 2015 00:28:01 -0500 Steve French <[email protected]> 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 <[email protected]>
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.
Quoted 46 lines
--- fs/cifs/smb2pdu.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-)fs/cifs/smb2pdu.c +8
-5@@ -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; } }
Signature · 1 line
Jeff Layton <[email protected]>
Re: [PATCH 3/4] [SMB3] Fix dereference before null check warning
Quoted 8 lines · Jeff Layton
Quoted 5 lines · On Fri, 27 Mar 2015 00:28:01 -0500 Steve French <[email protected]> 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.
Quoted 7 lines
Quoted 3 lines
Reported by Coverity (CID 1042666)
Signed-off-by Steve French <[email protected]>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.
I don't think it really matters much one way or another but I agree it would be a bug to pass in a null tcon to SMB2_ioctl.
On the other hand ... if there are any paths where tcon might be null (other than SessionSetup and NegProt and TCon itself) due to bug, SMB2/SMB3 ioctl/fsctl would be the one since there are various strange operations (such as security related calls such as validate negotiate for example) that either call it now or will need to call it as additional SMB2/SMB3 ioctls are added. I didn't see any harm in checking for null tcon, although clearly passing in a null tcon would be a bug - this is one code path where I don't mind checking since there are some counterintuitive things which SMB2 ioctl/fsctl protocol operations do.
Quoted 48 lines
Quoted 46 lines
--- fs/cifs/smb2pdu.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-)fs/cifs/smb2pdu.c +8
-5@@ -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; } }
Signature · 3 lines
Thanks, Steve
Re: [PATCH 3/4] [SMB3] Fix dereference before null check warning
Quoted 20 lines · On Wed, 1 Apr 2015 00:00:57 -0500 Steve French <[email protected]> wrote:
Quoted 8 lines · Jeff Layton
Quoted 5 lines · On Fri, 27 Mar 2015 00:28:01 -0500 Steve French <[email protected]> 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.Quoted 7 lines
Quoted 3 lines
Reported by Coverity (CID 1042666)
Signed-off-by Steve French <[email protected]>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.
I don't think it really matters much one way or another but I agree it would be a bug to pass in a null tcon to
SMB2_ioctl.
Quoted 11 lines
On the other hand ... if there are any paths where tcon might be null (other than SessionSetup and NegProt and TCon itself) due to bug, SMB2/SMB3 ioctl/fsctl would be the one since there are various strange operations (such as security related calls such as validate negotiate for example) that either call it now or will need to call it as additional SMB2/SMB3 ioctls are added. I didn't see any harm in checking for null tcon, although clearly passing in a null tcon would be a bug - this is one code path where I don't mind checking since there are some counterintuitive things which SMB2 ioctl/fsctl protocol operations do.
I guess my thinking was that an ioctl syscall requires that you have an open file, and that requires a fully-established tcon with cifs.ko. So I don't quite understand how you could get into SMB2_ioctl and not have a valid tcon.
Bogus NULL pointer checks like this may seem harmless, but they tend to lead toward the papering over of real bugs. My suggestion would be to get rid of any pretense that passing in a NULL tcon is OK here.
Quoted 52 lines
Quoted 49 lines
Quoted 47 lines
--- fs/cifs/smb2pdu.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-)fs/cifs/smb2pdu.c +8
-5@@ -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; } }
Signature · 1 line
Jeff Layton <[email protected]>
PATCH 4/4 Fix coverity warning
In reply to Steve FrenchCoverity reports a warning for referencing the beginning of the SMB2/SMB3 frame using the ProtocolId field as an array. Although it works the same either way, this patch should quiet the warning and might be a little clearer.
Reported by Coverity (CID 741269)
--- fs/cifs/smb2misc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/cifs/smb2misc.c +1 -1
@@ -322,7 +322,7 @@ smb2_get_data_area_len(int *off, int *len, struct smb2_hdr *hdr)/* return pointer to beginning of data area, ie offset from SMB start */ if ((*off !=0 ) && (*len !=0 )) -return hdr->ProtocolId + *off; +return (char *)(&hdr->ProtocolId[0 ]) + *off;else return NULL ; }
Signature · 1 line
1.9.1
Re: [PATCH 4/4] [SMB3] Fix coverity warning
Looks correct.
Quoted 32 lines · Steve French
Coverity reports a warning for referencing the beginning of the SMB2/SMB3 frame using the ProtocolId field as an array. Although it works the same either way, this patch should quiet the warning and might be a little clearer.
Reported by Coverity (CID 741269)
Signed-off-by Steve French <[email protected]>--- fs/cifs/smb2misc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)fs/cifs/smb2misc.c +1
-2@@ -322,7 +322,7 @@ smb2_get_data_area_len(int *off, int *len, struct smb2_hdr *hdr)/* return pointer to beginning of data area, ie offset from SMB start */ if ((*off !=0 ) && (*len !=0 )) -return hdr->ProtocolId + *off; +return (char *)(&hdr->ProtocolId[0 ]) + *off;else return NULL ; } --1.9.1
--
To unsubscribe from this list: send the line "unsubscribe linux-cifs" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 4/4] [SMB3] Fix coverity warning
In reply to Steve FrenchQuoted 8 lines · Steve French
Coverity reports a warning for referencing the beginning of the SMB2/SMB3 frame using the ProtocolId field as an array. Although it works the same either way, this patch should quiet the warning and might be a little clearer.
Reported by Coverity (CID 741269)
Signed-off-by Steve French <[email protected]>
Quoted 17 lines
--- fs/cifs/smb2misc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)fs/cifs/smb2misc.c +1
-1@@ -322,7 +322,7 @@ smb2_get_data_area_len(int *off, int *len, struct smb2_hdr *hdr)/* return pointer to beginning of data area, ie offset from SMB start */ if ((*off !=0 ) && (*len !=0 )) -return hdr->ProtocolId + *off; +return (char *)(&hdr->ProtocolId[0 ]) + *off;else return NULL ; }
Re: [PATCH 4/4] [SMB3] Fix coverity warning
In reply to Steve FrenchQuoted 17 lines · On Fri, 27 Mar 2015 00:28:02 -0500 Steve French…
Coverity reports a warning for referencing the beginning of the SMB2/SMB3 frame using the ProtocolId field as an array. Although it works the same either way, this patch should quiet the warning and might be a little clearer.
Reported by Coverity (CID 741269)
Signed-off-by Steve French <[email protected]>--- fs/cifs/smb2misc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)fs/cifs/smb2misc.c +0
-0
fs/cifs/smb2misc.c smb2_get_data_area_len(int *off, int *len, struct smb2_hdr *hdr) · line 328
Quoted 8 lines
fs/cifs/smb2misc.c +1
-1@@ -322,7 +322,7 @@ smb2_get_data_area_len(int *off, int *len, struct smb2_hdr *hdr)/* return pointer to beginning of data area, ie offset from SMB start */ if ((*off !=0 ) && (*len !=0 )) -return hdr->ProtocolId + *off; +return (char *)(&hdr->ProtocolId[0 ]) + *off;else return NULL ; }