Skip to content

Commit 6ca9818

Browse files
wenchao-haomartinkpetersen
authored andcommitted
scsi: Revert "scsi: core: Do not increase scsi_device's iorequest_cnt if dispatch failed"
The "atomic_inc(&cmd->device->iorequest_cnt)" in scsi_queue_rq() would cause kernel panic because cmd->device may be freed after returning from scsi_dispatch_cmd(). This reverts commit cfee29f. Signed-off-by: Wenchao Hao <[email protected]> Reported-by: Ming Lei <[email protected]> Closes: https://lore.kernel.org/r/[email protected] Link: https://lore.kernel.org/r/[email protected] Reviewed-by: Ming Lei <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
1 parent 4e81a6c commit 6ca9818

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

drivers/scsi/scsi_lib.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1463,6 +1463,8 @@ static int scsi_dispatch_cmd(struct scsi_cmnd *cmd)
14631463
struct Scsi_Host *host = cmd->device->host;
14641464
int rtn = 0;
14651465

1466+
atomic_inc(&cmd->device->iorequest_cnt);
1467+
14661468
/* check if the device is still usable */
14671469
if (unlikely(cmd->device->sdev_state == SDEV_DEL)) {
14681470
/* in SDEV_DEL we error all commands. DID_NO_CONNECT
@@ -1761,7 +1763,6 @@ static blk_status_t scsi_queue_rq(struct blk_mq_hw_ctx *hctx,
17611763
goto out_dec_host_busy;
17621764
}
17631765

1764-
atomic_inc(&cmd->device->iorequest_cnt);
17651766
return BLK_STS_OK;
17661767

17671768
out_dec_host_busy:

0 commit comments

Comments
 (0)