Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 98096d8a authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Sagi Grimberg
Browse files

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: default avatarChristoph Hellwig <hch@lst.de>
Reviewed-by: default avatarJay Freyensee <james_p_freyensee@linux.intel.com>
Signed-off-by: default avatarSagi Grimberg <sagi@grimberg.me>
parent 7a665d2f
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -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)