Skip to content

Commit

Permalink
scsi: core: scsi_logging: Fix a BUG
Browse files Browse the repository at this point in the history
The request_queue may be NULL in a request, for example when it comes from
scsi_ioctl_reset(). Check it before use.

Fixes: f3fa33a ("block: remove the ->rq_disk field in struct request")
Link: https://lore.kernel.org/r/20220324134603.28463-1-thenzl@redhat.com
Reported-by: Changhui Zhong <czhong@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Tomas Henzl <thenzl@redhat.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
  • Loading branch information
Tomas Henzl authored and Martin K. Petersen committed Mar 30, 2022
1 parent 8ee15ea commit f06aa52
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/scsi/scsi_logging.c
Original file line number Diff line number Diff line change
@@ -30,7 +30,7 @@ static inline const char *scmd_name(const struct scsi_cmnd *scmd)
{
struct request *rq = scsi_cmd_to_rq((struct scsi_cmnd *)scmd);

if (!rq->q->disk)
if (!rq->q || !rq->q->disk)
return NULL;
return rq->q->disk->disk_name;
}

0 comments on commit f06aa52

Please sign in to comment.