scsi: scsi_debug: Fix sdebug_blk_mq_poll() in_use_bm bitmap use
The in_use_bm bitmap of struct sdebug_queue should be accessed under protection of the qc_lock spinlock. Make sure that this lock is taken before calling find_first_bit() at the beginning of the function sdebug_blk_mq_poll(). Link: https://lore.kernel.org/r/20220404045547.579887-1-damien.lemoal@opensource.wdc.com Fixes: 3fd07aecb750 ("scsi: scsi_debug: Fix qc_lock use in sdebug_blk_mq_poll()") Acked-by: Douglas Gilbert <dgilbert@interlog.com> Signed-off-by: Damien Le Moal <damien.lemoal@opensource.wdc.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
This commit is contained in:
parent
5f3ecd7447
commit
6a0d0ae3e8
@ -7519,12 +7519,13 @@ static int sdebug_blk_mq_poll(struct Scsi_Host *shost, unsigned int queue_num)
|
|||||||
struct sdebug_defer *sd_dp;
|
struct sdebug_defer *sd_dp;
|
||||||
|
|
||||||
sqp = sdebug_q_arr + queue_num;
|
sqp = sdebug_q_arr + queue_num;
|
||||||
qc_idx = find_first_bit(sqp->in_use_bm, sdebug_max_queue);
|
|
||||||
if (qc_idx >= sdebug_max_queue)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
spin_lock_irqsave(&sqp->qc_lock, iflags);
|
spin_lock_irqsave(&sqp->qc_lock, iflags);
|
||||||
|
|
||||||
|
qc_idx = find_first_bit(sqp->in_use_bm, sdebug_max_queue);
|
||||||
|
if (qc_idx >= sdebug_max_queue)
|
||||||
|
goto unlock;
|
||||||
|
|
||||||
for (first = true; first || qc_idx + 1 < sdebug_max_queue; ) {
|
for (first = true; first || qc_idx + 1 < sdebug_max_queue; ) {
|
||||||
if (first) {
|
if (first) {
|
||||||
first = false;
|
first = false;
|
||||||
@ -7589,6 +7590,7 @@ static int sdebug_blk_mq_poll(struct Scsi_Host *shost, unsigned int queue_num)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unlock:
|
||||||
spin_unlock_irqrestore(&sqp->qc_lock, iflags);
|
spin_unlock_irqrestore(&sqp->qc_lock, iflags);
|
||||||
|
|
||||||
if (num_entries > 0)
|
if (num_entries > 0)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user