[<prev] [next>] [day] [month] [year] [list]
Message-Id: <20210816201042.1294196-1-trix@redhat.com>
Date: Mon, 16 Aug 2021 13:10:42 -0700
From: trix@...hat.com
To: hare@...nel.org, jejb@...ux.ibm.com, martin.petersen@...cle.com
Cc: linux-scsi@...r.kernel.org, linux-kernel@...r.kernel.org,
Tom Rix <trix@...hat.com>
Subject: [PATCH] scsi: myrb: reorder status check of myrb_get_rbld_progress()
From: Tom Rix <trix@...hat.com>
Static analysis reports this representative problem
myrb.c:1909: warning: The left operand of '!=' is a garbage value
if (rbld_buf.ldev_num != sdev->id ||
~~~~~~~~~~~~~~~~~ ^
myrb_get_rbld_progress() can return without setting rbld_buf.ldev_num.
Reorder the checks in the if () statement so a failure short circuits
the rbld_buf.ldev_num check.
Fixes: 081ff398c56c ("scsi: myrb: Add Mylex RAID controller (block interface)")
Signed-off-by: Tom Rix <trix@...hat.com>
---
drivers/scsi/myrb.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/scsi/myrb.c b/drivers/scsi/myrb.c
index a4a88323e0209..132aec8e51e5b 100644
--- a/drivers/scsi/myrb.c
+++ b/drivers/scsi/myrb.c
@@ -1906,8 +1906,8 @@ static ssize_t rebuild_show(struct device *dev,
status = myrb_get_rbld_progress(cb, &rbld_buf);
- if (rbld_buf.ldev_num != sdev->id ||
- status != MYRB_STATUS_SUCCESS)
+ if (status != MYRB_STATUS_SUCCESS ||
+ rbld_buf.ldev_num != sdev->id)
return snprintf(buf, 32, "not rebuilding\n");
return snprintf(buf, 32, "rebuilding block %u of %u\n",
--
2.26.3
Powered by blists - more mailing lists