mirror of
https://github.com/torvalds/linux.git
synced 2024-11-02 02:01:29 +00:00
nvme-fc: avoid memory corruption caused by calling nvmf_free_options() twice
Do not call nvmf_free_options() from the nvme_fc_ctlr destructor if nvme_fc_create_ctrl() returns an error, because nvmf_create_ctrl() frees the options when an error is returned. Signed-off-by: Ewan D. Milne <emilne@redhat.com> Signed-off-by: Christoph Hellwig <hch@lst.de>
This commit is contained in:
parent
bbe3012b73
commit
de41447aac
@ -1716,7 +1716,8 @@ nvme_fc_ctrl_free(struct kref *ref)
|
|||||||
nvme_fc_rport_put(ctrl->rport);
|
nvme_fc_rport_put(ctrl->rport);
|
||||||
|
|
||||||
ida_simple_remove(&nvme_fc_ctrl_cnt, ctrl->cnum);
|
ida_simple_remove(&nvme_fc_ctrl_cnt, ctrl->cnum);
|
||||||
nvmf_free_options(ctrl->ctrl.opts);
|
if (ctrl->ctrl.opts)
|
||||||
|
nvmf_free_options(ctrl->ctrl.opts);
|
||||||
kfree(ctrl);
|
kfree(ctrl);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2807,6 +2808,7 @@ nvme_fc_init_ctrl(struct device *dev, struct nvmf_ctrl_options *opts,
|
|||||||
|
|
||||||
ret = nvme_fc_create_association(ctrl);
|
ret = nvme_fc_create_association(ctrl);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
|
ctrl->ctrl.opts = NULL;
|
||||||
/* initiate nvme ctrl ref counting teardown */
|
/* initiate nvme ctrl ref counting teardown */
|
||||||
nvme_uninit_ctrl(&ctrl->ctrl);
|
nvme_uninit_ctrl(&ctrl->ctrl);
|
||||||
nvme_put_ctrl(&ctrl->ctrl);
|
nvme_put_ctrl(&ctrl->ctrl);
|
||||||
|
Loading…
Reference in New Issue
Block a user