Skip to content

Commit

Permalink
scsi: Fix a harmless double shift bug
Browse files Browse the repository at this point in the history
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: f134270 ("scsi: Do not rely on blk-mq for double completions")
Reviewed-by: Keith Busch <keith.busch@intel.com>
Acked-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
  • Loading branch information
Dan Carpenter authored and Jens Axboe committed Dec 8, 2018
1 parent 3236b45 commit 29cadd2
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion include/scsi/scsi_cmnd.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 29cadd2

Please sign in to comment.