[PATCH V2] nvme: free pre-allocated queue if create ioq goes wrong

Keith Busch keith.busch at intel.com
Sun Jan 14 18:00:16 PST 2018


On Mon, Jan 15, 2018 at 06:00:50AM +0900, Minwoo Im wrote:
>  static const struct blk_mq_ops nvme_mq_admin_ops = {
>  	.queue_rq	= nvme_queue_rq,
>  	.complete	= nvme_pci_complete_rq,
> @@ -1637,8 +1636,10 @@ static int nvme_create_io_queues(struct nvme_dev *dev)
>  	max = min(dev->max_qid, dev->ctrl.queue_count - 1);
>  	for (i = dev->online_queues; i <= max; i++) {
>  		ret = nvme_create_queue(dev->queues[i], i);
> -		if (ret)
> +		if (ret) {
> +			nvme_free_queues(dev, dev->online_queues);
>  			break;
> +		}
>  	}

Unless this is the very first pass at initialisation, I don't think we
can free queues until after blk_mq_update_nr_hw_queues since the hctx
could otherwise point to freed memory.



More information about the Linux-nvme mailing list