dm rq: check blk_mq_register_dev() return value in dm_mq_init_request_queue()
authorBart Van Assche <bart.vanassche@sandisk.com>
Thu, 27 Apr 2017 17:11:19 +0000 (10:11 -0700)
committerMike Snitzer <snitzer@redhat.com>
Thu, 27 Apr 2017 21:08:40 +0000 (17:08 -0400)
Otherwise the request-based DM blk-mq request_queue will be put into
service without being properly exported via sysfs.

Cc: stable@vger.kernel.org
Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
Reviewed-by: Hannes Reinecke <hare@suse.com>
Cc: Christoph Hellwig <hch@lst.de>
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
drivers/md/dm-rq.c

index 90756a56c4d383cdbc2e0a1ff728c1c479600b8a..a6e8da9da7a4dd65550bd1753a7563eb487d6863 100644 (file)
@@ -809,10 +809,14 @@ int dm_mq_init_request_queue(struct mapped_device *md, struct dm_table *t)
        dm_init_md_queue(md);
 
        /* backfill 'mq' sysfs registration normally done in blk_register_queue */
-       blk_mq_register_dev(disk_to_dev(md->disk), q);
+       err = blk_mq_register_dev(disk_to_dev(md->disk), q);
+       if (err)
+               goto out_cleanup_queue;
 
        return 0;
 
+out_cleanup_queue:
+       blk_cleanup_queue(q);
 out_tag_set:
        blk_mq_free_tag_set(md->tag_set);
 out_kfree_tag_set: