Commit 03504e3b authored by Wu Bo's avatar Wu Bo Committed by Christoph Hellwig

nvme-loop: fix memory leak in nvme_loop_create_ctrl()

When creating loop ctrl in nvme_loop_create_ctrl(), if nvme_init_ctrl()
fails, the loop ctrl should be freed before jumping to the "out" label.

Fixes: 3a85a5de ("nvme-loop: add a NVMe loopback host driver")
Signed-off-by: default avatarWu Bo <wubo40@huawei.com>
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
parent fec356a6
......@@ -590,8 +590,10 @@ static struct nvme_ctrl *nvme_loop_create_ctrl(struct device *dev,
ret = nvme_init_ctrl(&ctrl->ctrl, dev, &nvme_loop_ctrl_ops,
0 /* no quirks, we're perfect! */);
if (ret)
if (ret) {
kfree(ctrl);
goto out;
}
if (!nvme_change_ctrl_state(&ctrl->ctrl, NVME_CTRL_CONNECTING))
WARN_ON_ONCE(1);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment