aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeff Moyer <jmoyer@redhat.com>2017-01-09 15:20:31 -0500
committerJens Axboe <axboe@fb.com>2017-01-10 15:30:50 -0500
commit25b4acfc7de0fc4da3bfea3a316f7282c6fbde81 (patch)
tree2a499c0910f948316a23003cacc43a29619299a5
parenta14d749fcebe97ddf6af6db3d1f6ece85c9ddcb9 (diff)
nbd: blk_mq_init_queue returns an error code on failure, not NULL
Additionally, don't assign directly to disk->queue, otherwise blk_put_queue (called via put_disk) will choke (panic) on the errno stored there. Bug found by code inspection after Omar found a similar issue in virtio_blk. Compile-tested only. Signed-off-by: Jeff Moyer <jmoyer@redhat.com> Reviewed-by: Omar Sandoval <osandov@fb.com> Reviewed-by: Josef Bacik <jbacik@fb.com> Signed-off-by: Jens Axboe <axboe@fb.com>
-rw-r--r--drivers/block/nbd.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c
index 38c576f76d36..50a2020b5b72 100644
--- a/drivers/block/nbd.c
+++ b/drivers/block/nbd.c
@@ -1042,6 +1042,7 @@ static int __init nbd_init(void)
1042 return -ENOMEM; 1042 return -ENOMEM;
1043 1043
1044 for (i = 0; i < nbds_max; i++) { 1044 for (i = 0; i < nbds_max; i++) {
1045 struct request_queue *q;
1045 struct gendisk *disk = alloc_disk(1 << part_shift); 1046 struct gendisk *disk = alloc_disk(1 << part_shift);
1046 if (!disk) 1047 if (!disk)
1047 goto out; 1048 goto out;
@@ -1067,12 +1068,13 @@ static int __init nbd_init(void)
1067 * every gendisk to have its very own request_queue struct. 1068 * every gendisk to have its very own request_queue struct.
1068 * These structs are big so we dynamically allocate them. 1069 * These structs are big so we dynamically allocate them.
1069 */ 1070 */
1070 disk->queue = blk_mq_init_queue(&nbd_dev[i].tag_set); 1071 q = blk_mq_init_queue(&nbd_dev[i].tag_set);
1071 if (!disk->queue) { 1072 if (IS_ERR(q)) {
1072 blk_mq_free_tag_set(&nbd_dev[i].tag_set); 1073 blk_mq_free_tag_set(&nbd_dev[i].tag_set);
1073 put_disk(disk); 1074 put_disk(disk);
1074 goto out; 1075 goto out;
1075 } 1076 }
1077 disk->queue = q;
1076 1078
1077 /* 1079 /*
1078 * Tell the block layer that we are not a rotational device 1080 * Tell the block layer that we are not a rotational device