Skip to content

Commit 98e3528

Browse files
rosslagerwallChristoph Hellwig
authored andcommitted
nvme-fc: fix initialization order
ctrl->ops is used by nvme_alloc_admin_tag_set() but set by nvme_init_ctrl() so reorder the calls to avoid a NULL pointer dereference. Fixes: 6dfba1c ("nvme-fc: use the tagset alloc/free helpers") Signed-off-by: Ross Lagerwall <[email protected]> Reviewed-by: Sagi Grimberg <[email protected]> Signed-off-by: Christoph Hellwig <[email protected]>
1 parent 955bc12 commit 98e3528

File tree

1 file changed

+8
-10
lines changed
  • drivers/nvme/host

1 file changed

+8
-10
lines changed

drivers/nvme/host/fc.c

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3521,13 +3521,6 @@ nvme_fc_init_ctrl(struct device *dev, struct nvmf_ctrl_options *opts,
35213521

35223522
nvme_fc_init_queue(ctrl, 0);
35233523

3524-
ret = nvme_alloc_admin_tag_set(&ctrl->ctrl, &ctrl->admin_tag_set,
3525-
&nvme_fc_admin_mq_ops,
3526-
struct_size((struct nvme_fcp_op_w_sgl *)NULL, priv,
3527-
ctrl->lport->ops->fcprqst_priv_sz));
3528-
if (ret)
3529-
goto out_free_queues;
3530-
35313524
/*
35323525
* Would have been nice to init io queues tag set as well.
35333526
* However, we require interaction from the controller
@@ -3537,10 +3530,17 @@ nvme_fc_init_ctrl(struct device *dev, struct nvmf_ctrl_options *opts,
35373530

35383531
ret = nvme_init_ctrl(&ctrl->ctrl, dev, &nvme_fc_ctrl_ops, 0);
35393532
if (ret)
3540-
goto out_cleanup_tagset;
3533+
goto out_free_queues;
35413534

35423535
/* at this point, teardown path changes to ref counting on nvme ctrl */
35433536

3537+
ret = nvme_alloc_admin_tag_set(&ctrl->ctrl, &ctrl->admin_tag_set,
3538+
&nvme_fc_admin_mq_ops,
3539+
struct_size((struct nvme_fcp_op_w_sgl *)NULL, priv,
3540+
ctrl->lport->ops->fcprqst_priv_sz));
3541+
if (ret)
3542+
goto fail_ctrl;
3543+
35443544
spin_lock_irqsave(&rport->lock, flags);
35453545
list_add_tail(&ctrl->ctrl_list, &rport->ctrl_list);
35463546
spin_unlock_irqrestore(&rport->lock, flags);
@@ -3592,8 +3592,6 @@ nvme_fc_init_ctrl(struct device *dev, struct nvmf_ctrl_options *opts,
35923592

35933593
return ERR_PTR(-EIO);
35943594

3595-
out_cleanup_tagset:
3596-
nvme_remove_admin_tag_set(&ctrl->ctrl);
35973595
out_free_queues:
35983596
kfree(ctrl->queues);
35993597
out_free_ida:

0 commit comments

Comments
 (0)