public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] scsi_debug: test always evaluates to false, || should be used instead
@ 2015-01-22 11:20 Colin King
  2015-01-22 11:31 ` Douglas Gilbert
  0 siblings, 1 reply; 2+ messages in thread
From: Colin King @ 2015-01-22 11:20 UTC (permalink / raw)
  To: James E.J. Bottomley, linux-scsi; +Cc: linux-kernel

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

cppcheck found the following issue:
(warning) Logical conjunction always evaluates to false:
  alloc_len < 4 && alloc_len > 65535.

..the test should be instead:

  if (alloc_len < 4 || alloc_len > 65536)

This error was introduced by recent commit 38d5c8336e60bf6e53a1da9
("scsi_debug: add Report supported opcodes+tmfs; Compare and write")

Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 drivers/scsi/scsi_debug.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/scsi_debug.c b/drivers/scsi/scsi_debug.c
index 7b8b51b..63a2e1f 100644
--- a/drivers/scsi/scsi_debug.c
+++ b/drivers/scsi/scsi_debug.c
@@ -1623,7 +1623,7 @@ resp_rsup_opcodes(struct scsi_cmnd *scp, struct sdebug_dev_info *devip)
 	req_opcode = cmd[3];
 	req_sa = get_unaligned_be16(cmd + 4);
 	alloc_len = get_unaligned_be32(cmd + 6);
-	if (alloc_len < 4 && alloc_len > 0xffff) {
+	if (alloc_len < 4 || alloc_len > 0xffff) {
 		mk_sense_invalid_fld(scp, SDEB_IN_CDB, 6, -1);
 		return check_condition_result;
 	}
-- 
2.1.4


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

* Re: [PATCH] scsi_debug: test always evaluates to false, || should be used instead
  2015-01-22 11:20 [PATCH] scsi_debug: test always evaluates to false, || should be used instead Colin King
@ 2015-01-22 11:31 ` Douglas Gilbert
  0 siblings, 0 replies; 2+ messages in thread
From: Douglas Gilbert @ 2015-01-22 11:31 UTC (permalink / raw)
  To: Colin King, James E.J. Bottomley, linux-scsi; +Cc: linux-kernel

On 15-01-22 12:20 PM, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> cppcheck found the following issue:
> (warning) Logical conjunction always evaluates to false:
>    alloc_len < 4 && alloc_len > 65535.
>
> ..the test should be instead:
>
>    if (alloc_len < 4 || alloc_len > 65536)
>
> This error was introduced by recent commit 38d5c8336e60bf6e53a1da9
> ("scsi_debug: add Report supported opcodes+tmfs; Compare and write")
>
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>   drivers/scsi/scsi_debug.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/scsi/scsi_debug.c b/drivers/scsi/scsi_debug.c
> index 7b8b51b..63a2e1f 100644
> --- a/drivers/scsi/scsi_debug.c
> +++ b/drivers/scsi/scsi_debug.c
> @@ -1623,7 +1623,7 @@ resp_rsup_opcodes(struct scsi_cmnd *scp, struct sdebug_dev_info *devip)
>   	req_opcode = cmd[3];
>   	req_sa = get_unaligned_be16(cmd + 4);
>   	alloc_len = get_unaligned_be32(cmd + 6);
> -	if (alloc_len < 4 && alloc_len > 0xffff) {
> +	if (alloc_len < 4 || alloc_len > 0xffff) {
>   		mk_sense_invalid_fld(scp, SDEB_IN_CDB, 6, -1);
>   		return check_condition_result;
>   	}
>

I have presented this fix twice already. Most recently in
"[PATCH] [RESEND] scsi_debug: fix sanity check in resp_rsup_opcodes"
20150102. So one more time, with feeling:

Acked-by: Douglas Gilbert <dgilbert@interlog.com>





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

end of thread, other threads:[~2015-01-22 11:31 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-01-22 11:20 [PATCH] scsi_debug: test always evaluates to false, || should be used instead Colin King
2015-01-22 11:31 ` Douglas Gilbert

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox