Skip to contentSkip to conversation

scsi_logging: fix a BUG

PATCH Applied Tomas Henzl 3 participants 4 messages Mar 24, 2022 – Apr 7, 2022 SCSI

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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 before use.

Fixes f3fa33acca9f ("block: remove the ->rq_disk field in struct request")
---
 drivers/scsi/scsi_logging.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/scsi_logging.c +1 -1
index 1f8f80b2dbfc..a9f8de5e9639 100644
@@ -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;
 }
Signature · 1 line
2.35.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 8 lines · Tomas Henzl

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

Fixes f3fa33acca9f ("block: remove the ->rq_disk field in struct request")

As a quick fix this look good:

but I really wonder if we should print some other identifier if the disk name is not available.

#2 lore raw
In reply to Tomas Henzl

Tomas,

Quoted 2 lines

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

Applied to 5.18/scsi-staging, thanks!

Signature · 1 line
Martin K. Petersen	Oracle Linux Engineering
#3 lore raw
In reply to Tomas Henzl
Quoted 8 lines · Tomas Henzl

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

Fixes f3fa33acca9f ("block: remove the ->rq_disk field in struct request")

[...]

Applied to 5.18/scsi-fixes, thanks!

[1/1] scsi_logging: fix a BUG

      https://git.kernel.org/mkp/scsi/c/f06aa52cb272
Signature · 1 line
Martin K. Petersen	Oracle Linux Engineering