diff mbox series

Minor fix for problem noted by coverity scan

Message ID CAH2r5msVx8dRk18eJVFCPtNJkZAJC9PKf2o2_FZh4xFSmbc0og@mail.gmail.com
State New
Headers show
Series Minor fix for problem noted by coverity scan | expand

Commit Message

Steve French Nov. 14, 2018, 7:40 a.m. UTC

Comments

ronnie sahlberg Nov. 14, 2018, 9:09 a.m. UTC | #1
Reviewed-by: Ronnie Sahlberg <lsahlber@redhat.com>
On Wed, Nov 14, 2018 at 5:41 PM Steve French <smfrench@gmail.com> wrote:
>
> --
> Thanks,
>
> Steve
Steve French Nov. 15, 2018, 6:38 a.m. UTC | #2
One more ...


On Wed, Nov 14, 2018 at 1:40 AM Steve French <smfrench@gmail.com> wrote:
>
> --
> Thanks,
>
> Steve
ronnie sahlberg Nov. 15, 2018, 7:39 a.m. UTC | #3
Reviewed-by: Ronnie Sahlberg <lsahlber@redhat.com>
On Thu, Nov 15, 2018 at 4:38 PM Steve French <smfrench@gmail.com> wrote:
>
> One more ...
>
>
> On Wed, Nov 14, 2018 at 1:40 AM Steve French <smfrench@gmail.com> wrote:
> >
> > --
> > Thanks,
> >
> > Steve
>
>
>
> --
> Thanks,
>
> Steve
diff mbox series

Patch

From 530a883f45658d1590d3503d73c6f7dfa283f412 Mon Sep 17 00:00:00 2001
From: Steve French <stfrench@microsoft.com>
Date: Wed, 14 Nov 2018 01:37:39 -0600
Subject: [PATCH] cifs: smb2 commands can not be negative, remove confusing
 check

As Coverity points out le16_to_cpu(midEntry->Command) can not be less than zero.

Detected by CoverityScan, CID#1438650 ("Macro compares unsigned to 0")

Signed-off-by: Steve French <stfrench@microsoft.com>
---
 fs/cifs/transport.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/fs/cifs/transport.c b/fs/cifs/transport.c
index 83ff0c25710d..5be7302853b6 100644
--- a/fs/cifs/transport.c
+++ b/fs/cifs/transport.c
@@ -126,9 +126,11 @@  DeleteMidQEntry(struct mid_q_entry *midEntry)
 	if ((slow_rsp_threshold != 0) &&
 	    time_after(now, midEntry->when_alloc + (slow_rsp_threshold * HZ)) &&
 	    (midEntry->command != command)) {
-		/* smb2slowcmd[NUMBER_OF_SMB2_COMMANDS] counts by command */
-		if ((le16_to_cpu(midEntry->command) < NUMBER_OF_SMB2_COMMANDS) &&
-		    (le16_to_cpu(midEntry->command) >= 0))
+		/*
+		 * smb2slowcmd[NUMBER_OF_SMB2_COMMANDS] counts by command
+		 * NB: le16_to_cpu returns unsigned so can not be negative below
+		 */
+		if (le16_to_cpu(midEntry->command) < NUMBER_OF_SMB2_COMMANDS)
 			cifs_stats_inc(&midEntry->server->smb2slowcmd[le16_to_cpu(midEntry->command)]);
 
 		trace_smb3_slow_rsp(le16_to_cpu(midEntry->command),
-- 
2.17.1