Commit e8841656 authored by Konrad Sztyber's avatar Konrad Sztyber Committed by Jim Harris
Browse files

nvmf: add nvmf_host_free()



It'll make the error handling in spdk_nvmf_subsystem_add_host_ext() a
bit simpler when we add more fields to spdk_nvmf_host.

Signed-off-by: default avatarKonrad Sztyber <konrad.sztyber@intel.com>
Change-Id: I66d1ba7876a22ac952359dd5eaa587362eadf781
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/22806


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarSeung yeon Shin <syeon.shin@samsung.com>
Reviewed-by: default avatarBen Walker <ben@nvidia.com>
Community-CI: Mellanox Build Bot
Reviewed-by: default avatarJim Harris <jim.harris@samsung.com>
parent e53d15a2
Loading
Loading
Loading
Loading
+10 −4
Original line number Diff line number Diff line
@@ -313,13 +313,19 @@ spdk_nvmf_subsystem_create(struct spdk_nvmf_tgt *tgt,
	return subsystem;
}

static void
nvmf_host_free(struct spdk_nvmf_host *host)
{
	spdk_keyring_put_key(host->dhchap_key);
	free(host);
}

/* Must hold subsystem->mutex while calling this function */
static void
nvmf_subsystem_remove_host(struct spdk_nvmf_subsystem *subsystem, struct spdk_nvmf_host *host)
{
	spdk_keyring_put_key(host->dhchap_key);
	TAILQ_REMOVE(&subsystem->hosts, host, link);
	free(host);
	nvmf_host_free(host);
}

static void
@@ -1000,13 +1006,13 @@ spdk_nvmf_subsystem_add_host_ext(struct spdk_nvmf_subsystem *subsystem,
		if (!nvmf_auth_is_supported()) {
			SPDK_ERRLOG("NVMe in-band authentication is unsupported\n");
			pthread_mutex_unlock(&subsystem->mutex);
			free(host);
			nvmf_host_free(host);
			return -EINVAL;
		}
		host->dhchap_key = spdk_key_dup(key);
		if (host->dhchap_key == NULL) {
			pthread_mutex_unlock(&subsystem->mutex);
			free(host);
			nvmf_host_free(host);
			return -EINVAL;
		}
	}