pktcdvd: Check queue type before attaching to a queue
authorBart Van Assche <bart.vanassche@sandisk.com>
Wed, 31 May 2017 21:43:48 +0000 (14:43 -0700)
committerJens Axboe <axboe@fb.com>
Thu, 1 Jun 2017 19:10:43 +0000 (13:10 -0600)
Since the pktcdvd driver only supports request queues for which
struct scsi_request is the first member of their private request
data, refuse to register block layer queues for which struct
scsi_request is not the first member of the private data.

References: commit 82ed4db499b8 ("block: split scsi_request out of struct request")
Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
Reviewed-by: Hannes Reinecke <hare@suse.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Cc: Omar Sandoval <osandov@fb.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
drivers/block/pktcdvd.c

index 205b865ebeb9f123b12beb8d1a8c5179bbad7bd9..42e3c880a8a5d71cec9642bcb2784920d001a98d 100644 (file)
@@ -2583,6 +2583,11 @@ static int pkt_new_dev(struct pktcdvd_device *pd, dev_t dev)
        bdev = bdget(dev);
        if (!bdev)
                return -ENOMEM;
+       if (!blk_queue_scsi_passthrough(bdev_get_queue(bdev))) {
+               WARN_ONCE(true, "Attempt to register a non-SCSI queue\n");
+               bdput(bdev);
+               return -EINVAL;
+       }
        ret = blkdev_get(bdev, FMODE_READ | FMODE_NDELAY, NULL);
        if (ret)
                return ret;