On Fri, 2017-09-01 at 20:36 +0900, Damien Le Moal wrote: > +static struct scsi_disk *__zoned_scsi_disk(struct request_queue *q) > +{ > + struct scsi_device *sdp; > + struct scsi_disk *sdkp; > + > + if (!blk_queue_is_zoned(q)) { > + pr_err("zoned: Not a zoned block device\n"); > + return NULL; > + } > + > + sdp = scsi_device_from_queue(q); > + if (!sdp) { > + pr_err("zoned: Not a SCSI device\n"); > + return NULL; > + } > + > + sdkp = dev_get_drvdata(&sdp->sdev_gendev); > + if (WARN_ON(sdkp->disk->queue != q)) > + return NULL; > + > + return sdkp; > +}
Hello Damien, Can reading sdkp->disk->queue cause a kernel crash if sdp does not point at a SCSI device that is associated with a SCSI disk? How about using something like the code below to convert a request queue pointer into a SCSI disk pointer? static int lookup_disk(struct device *dev, void *data) { struct scsi_disk **sdkp = data; if (!*sdkp && dev->class == &sd_disk_class) *sdkp = to_scsi_disk(dev); return 0; } static struct scsi_disk *q_to_sdkp(struct request_queue *q) { struct scsi_device *sdp = scsi_device_from_queue(q); struct scsi_disk *sdkp = NULL; if (sdp) device_for_each_child(&sdp->sdev_gendev, &sdkp, lookup_disk); return sdkp; } Thanks, Bart.