提交 98096d8a 编写于 作者: C Christoph Hellwig 提交者: Sagi Grimberg

nvme-fabrics: get a reference when reusing a nvme_host structure

Without this we'll get a use after free after connecting two controller
using the same hostnqn and then disconnecting one of them.
Signed-off-by: NChristoph Hellwig <hch@lst.de>
Reviewed-by: NJay Freyensee <james_p_freyensee@linux.intel.com>
Signed-off-by: NSagi Grimberg <sagi@grimberg.me>
上级 7a665d2f
......@@ -47,8 +47,10 @@ static struct nvmf_host *nvmf_host_add(const char *hostnqn)
mutex_lock(&nvmf_hosts_mutex);
host = __nvmf_host_find(hostnqn);
if (host)
if (host) {
kref_get(&host->ref);
goto out_unlock;
}
host = kmalloc(sizeof(*host), GFP_KERNEL);
if (!host)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册