Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

scsi: core: scsi_logging: Fix a BUG

The request_queue may be NULL in a request, for example when it comes from
scsi_ioctl_reset(). Check it before use.

Fixes: f3fa33acca9f ("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>

authored by

Tomas Henzl and committed by
Martin K. Petersen
f06aa52c 8ee15ea7

+1 -1
+1 -1
drivers/scsi/scsi_logging.c
··· 30 30 { 31 31 struct request *rq = scsi_cmd_to_rq((struct scsi_cmnd *)scmd); 32 32 33 - if (!rq->q->disk) 33 + if (!rq->q || !rq->q->disk) 34 34 return NULL; 35 35 return rq->q->disk->disk_name; 36 36 }