diff mbox series

scsi_logging: fix a BUG

Message ID 20220324134603.28463-1-thenzl@redhat.com
State New
Headers show
Series scsi_logging: fix a BUG | expand

Commit Message

Tomas Henzl March 24, 2022, 1:46 p.m. UTC
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")

Reported-by: Changhui Zhong <czhong@redhat.com>
Signed-off-by: Tomas Henzl <thenzl@redhat.com>
---
 drivers/scsi/scsi_logging.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Christoph Hellwig March 24, 2022, 2:13 p.m. UTC | #1
On Thu, Mar 24, 2022 at 02:46:03PM +0100, Tomas Henzl wrote:
> 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")
> 
> Reported-by: Changhui Zhong <czhong@redhat.com>
> Signed-off-by: Tomas Henzl <thenzl@redhat.com>

As a quick fix this look good:

Reviewed-by: Christoph Hellwig <hch@lst.de>

but I really wonder if we should print some other identifier if the disk
name is not available.
Martin K. Petersen March 30, 2022, 3:29 a.m. UTC | #2
Tomas,

> 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!
Martin K. Petersen April 7, 2022, 1:35 p.m. UTC | #3
On Thu, 24 Mar 2022 14:46:03 +0100, Tomas Henzl wrote:

> 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
diff mbox series

Patch

diff --git a/drivers/scsi/scsi_logging.c b/drivers/scsi/scsi_logging.c
index 1f8f80b2dbfc..a9f8de5e9639 100644
--- a/drivers/scsi/scsi_logging.c
+++ b/drivers/scsi/scsi_logging.c
@@ -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;
 }