* [PATCH] scsi: Fix a harmless double shift bug
@ 2018-11-29 10:37 Dan Carpenter
2018-11-29 15:08 ` Keith Busch
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Dan Carpenter @ 2018-11-29 10:37 UTC (permalink / raw)
To: kernel-janitors
Smatch generates a warning:
drivers/scsi/scsi_lib.c:1656 scsi_mq_done() warn: test_bit() takes a bit number
The problem is that SCMD_STATE_COMPLETE is supposed to be bit number 0
and not a mask like "(1 << 0)". It is used like this:
if (test_and_set_bit(SCMD_STATE_COMPLETE, &scmd->state))
The test_and_set_bit() has a shift built in so it's a double left shift
and uses bit number 1 instead of number 0. This bug is harmless because
it's done consistently and it doesn't clash with any other flags.
Fixes: f1342709d18a ("scsi: Do not rely on blk-mq for double completions")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
include/scsi/scsi_cmnd.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/include/scsi/scsi_cmnd.h b/include/scsi/scsi_cmnd.h
index 3de905e205ce..d85e6befa26b 100644
--- a/include/scsi/scsi_cmnd.h
+++ b/include/scsi/scsi_cmnd.h
@@ -62,7 +62,7 @@ struct scsi_pointer {
#define SCMD_PRESERVED_FLAGS (SCMD_UNCHECKED_ISA_DMA | SCMD_INITIALIZED)
/* for scmd->state */
-#define SCMD_STATE_COMPLETE (1 << 0)
+#define SCMD_STATE_COMPLETE 0
struct scsi_cmnd {
struct scsi_request req;
--
2.11.0
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH] scsi: Fix a harmless double shift bug
2018-11-29 10:37 [PATCH] scsi: Fix a harmless double shift bug Dan Carpenter
@ 2018-11-29 15:08 ` Keith Busch
2018-12-08 3:20 ` Martin K. Petersen
2018-12-08 4:25 ` Jens Axboe
2 siblings, 0 replies; 4+ messages in thread
From: Keith Busch @ 2018-11-29 15:08 UTC (permalink / raw)
To: kernel-janitors
On Thu, Nov 29, 2018 at 01:37:10PM +0300, Dan Carpenter wrote:
> Smatch generates a warning:
>
> drivers/scsi/scsi_lib.c:1656 scsi_mq_done() warn: test_bit() takes a bit number
>
> The problem is that SCMD_STATE_COMPLETE is supposed to be bit number 0
> and not a mask like "(1 << 0)". It is used like this:
>
> if (test_and_set_bit(SCMD_STATE_COMPLETE, &scmd->state))
>
> The test_and_set_bit() has a shift built in so it's a double left shift
> and uses bit number 1 instead of number 0. This bug is harmless because
> it's done consistently and it doesn't clash with any other flags.
>
> Fixes: f1342709d18a ("scsi: Do not rely on blk-mq for double completions")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Nice catch, thanks for the fix.
Reviewed-by: Keith Busch <keith.busch@intel.com>
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH] scsi: Fix a harmless double shift bug
2018-11-29 10:37 [PATCH] scsi: Fix a harmless double shift bug Dan Carpenter
2018-11-29 15:08 ` Keith Busch
@ 2018-12-08 3:20 ` Martin K. Petersen
2018-12-08 4:25 ` Jens Axboe
2 siblings, 0 replies; 4+ messages in thread
From: Martin K. Petersen @ 2018-12-08 3:20 UTC (permalink / raw)
To: kernel-janitors
Jens,
This went in through your tree. Can you please pick this fix up?
> On Thu, Nov 29, 2018 at 01:37:10PM +0300, Dan Carpenter wrote:
>> Smatch generates a warning:
>>
>> drivers/scsi/scsi_lib.c:1656 scsi_mq_done() warn: test_bit() takes a bit number
>>
>> The problem is that SCMD_STATE_COMPLETE is supposed to be bit number 0
>> and not a mask like "(1 << 0)". It is used like this:
>>
>> if (test_and_set_bit(SCMD_STATE_COMPLETE, &scmd->state))
>>
>> The test_and_set_bit() has a shift built in so it's a double left shift
>> and uses bit number 1 instead of number 0. This bug is harmless because
>> it's done consistently and it doesn't clash with any other flags.
>>
>> Fixes: f1342709d18a ("scsi: Do not rely on blk-mq for double completions")
>> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
>
> Nice catch, thanks for the fix.
>
> Reviewed-by: Keith Busch <keith.busch@intel.com>
Acked-by: Martin K. Petersen <martin.petersen@oracle.com>
--
Martin K. Petersen Oracle Linux Engineering
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH] scsi: Fix a harmless double shift bug
2018-11-29 10:37 [PATCH] scsi: Fix a harmless double shift bug Dan Carpenter
2018-11-29 15:08 ` Keith Busch
2018-12-08 3:20 ` Martin K. Petersen
@ 2018-12-08 4:25 ` Jens Axboe
2 siblings, 0 replies; 4+ messages in thread
From: Jens Axboe @ 2018-12-08 4:25 UTC (permalink / raw)
To: kernel-janitors
On 12/7/18 8:20 PM, Martin K. Petersen wrote:
>
> Jens,
>
> This went in through your tree. Can you please pick this fix up?
Yep, applied, thanks Dan.
--
Jens Axboe
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2018-12-08 4:25 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-11-29 10:37 [PATCH] scsi: Fix a harmless double shift bug Dan Carpenter
2018-11-29 15:08 ` Keith Busch
2018-12-08 3:20 ` Martin K. Petersen
2018-12-08 4:25 ` Jens Axboe
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox