linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH][next] scsi: pm80xx: fix logic to break out of loop when register value is 2 or 3
@ 2019-11-20 13:50 Colin King
  2019-11-22  8:53 ` Jinpu Wang
  2019-11-27  2:30 ` Martin K. Petersen
  0 siblings, 2 replies; 3+ messages in thread
From: Colin King @ 2019-11-20 13:50 UTC (permalink / raw)
  To: Jack Wang, James E . J . Bottomley, Martin K . Petersen,
	Deepak Ukey, Viswas G, linux-scsi
  Cc: kernel-janitors, linux-kernel

From: Colin Ian King <colin.king@canonical.com>

The condition (reg_val != 2) || (reg_val != 3) will always be true because
reg_val cannot be equal to two different values at the same time. Fix this
by replacing the || operator with && so that the loop will loop if reg_val
is not a 2 and not a 3 as was originally intended.

Addresses-Coverity: ("Constant expression result")
Fixes: 50dc2f221455 ("scsi: pm80xx: Modified the logic to collect fatal dump")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 drivers/scsi/pm8001/pm80xx_hwi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/pm8001/pm80xx_hwi.c b/drivers/scsi/pm8001/pm80xx_hwi.c
index 19601138e889..d41908b23760 100644
--- a/drivers/scsi/pm8001/pm80xx_hwi.c
+++ b/drivers/scsi/pm8001/pm80xx_hwi.c
@@ -348,7 +348,7 @@ ssize_t pm80xx_get_fatal_dump(struct device *cdev,
 			do {
 				reg_val = pm8001_mr32(fatal_table_address,
 					MPI_FATAL_EDUMP_TABLE_STATUS);
-			} while (((reg_val != 2) || (reg_val != 3)) &&
+			} while (((reg_val != 2) && (reg_val != 3)) &&
 					time_before(jiffies, start));
 
 			if (reg_val < 2) {
-- 
2.24.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH][next] scsi: pm80xx: fix logic to break out of loop when register value is 2 or 3
  2019-11-20 13:50 [PATCH][next] scsi: pm80xx: fix logic to break out of loop when register value is 2 or 3 Colin King
@ 2019-11-22  8:53 ` Jinpu Wang
  2019-11-27  2:30 ` Martin K. Petersen
  1 sibling, 0 replies; 3+ messages in thread
From: Jinpu Wang @ 2019-11-22  8:53 UTC (permalink / raw)
  To: Colin King
  Cc: James E . J . Bottomley, Martin K . Petersen, Deepak Ukey,
	Viswas G, Linux SCSI Mailinglist, kernel-janitors, linux-kernel

On Wed, Nov 20, 2019 at 2:50 PM Colin King <colin.king@canonical.com> wrote:
>
> From: Colin Ian King <colin.king@canonical.com>
>
> The condition (reg_val != 2) || (reg_val != 3) will always be true because
> reg_val cannot be equal to two different values at the same time. Fix this
> by replacing the || operator with && so that the loop will loop if reg_val
> is not a 2 and not a 3 as was originally intended.
>
> Addresses-Coverity: ("Constant expression result")
> Fixes: 50dc2f221455 ("scsi: pm80xx: Modified the logic to collect fatal dump")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
looks fine. thanks Colin.
Acked-by: Jack Wang <jinpu.wang@cloud.ionos.com>
> ---
>  drivers/scsi/pm8001/pm80xx_hwi.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/scsi/pm8001/pm80xx_hwi.c b/drivers/scsi/pm8001/pm80xx_hwi.c
> index 19601138e889..d41908b23760 100644
> --- a/drivers/scsi/pm8001/pm80xx_hwi.c
> +++ b/drivers/scsi/pm8001/pm80xx_hwi.c
> @@ -348,7 +348,7 @@ ssize_t pm80xx_get_fatal_dump(struct device *cdev,
>                         do {
>                                 reg_val = pm8001_mr32(fatal_table_address,
>                                         MPI_FATAL_EDUMP_TABLE_STATUS);
> -                       } while (((reg_val != 2) || (reg_val != 3)) &&
> +                       } while (((reg_val != 2) && (reg_val != 3)) &&
>                                         time_before(jiffies, start));
>
>                         if (reg_val < 2) {
> --
> 2.24.0
>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH][next] scsi: pm80xx: fix logic to break out of loop when register value is 2 or 3
  2019-11-20 13:50 [PATCH][next] scsi: pm80xx: fix logic to break out of loop when register value is 2 or 3 Colin King
  2019-11-22  8:53 ` Jinpu Wang
@ 2019-11-27  2:30 ` Martin K. Petersen
  1 sibling, 0 replies; 3+ messages in thread
From: Martin K. Petersen @ 2019-11-27  2:30 UTC (permalink / raw)
  To: Colin King
  Cc: Jack Wang, James E . J . Bottomley, Martin K . Petersen,
	Deepak Ukey, Viswas G, linux-scsi, kernel-janitors, linux-kernel


Colin,

> The condition (reg_val != 2) || (reg_val != 3) will always be true
> because reg_val cannot be equal to two different values at the same
> time. Fix this by replacing the || operator with && so that the loop
> will loop if reg_val is not a 2 and not a 3 as was originally
> intended.

Applied to 5.5/scsi-queue, thanks!

-- 
Martin K. Petersen	Oracle Linux Engineering

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-11-27  2:30 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-20 13:50 [PATCH][next] scsi: pm80xx: fix logic to break out of loop when register value is 2 or 3 Colin King
2019-11-22  8:53 ` Jinpu Wang
2019-11-27  2:30 ` Martin K. Petersen

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).