Commit 9a684763 authored by Yash Raj Singh's avatar Yash Raj Singh Committed by Konrad Sztyber
Browse files

bdev/nvme: Fix spdk_bdev_nvme_create()



This patch fixes spdk_bdev_nvme_create function by ensuring that
base_name received is persisted until we create the bdevs. Current all
in-tree callers persist the string parameter that is passed, but we
want to support the case for out-of-tree callers which needs the string
parameter to be persisted.

Change-Id: I371842607f8360e83283b92ff9750f567fa375ca
Signed-off-by: default avatarYash Raj Singh <yash.rajsingh@nutanix.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/25209


Reviewed-by: default avatarJim Harris <jim.harris@nvidia.com>
Reviewed-by: default avatarShuhei Matsumoto <smatsumoto@nvidia.com>
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarKonrad Sztyber <konrad.sztyber@intel.com>
Community-CI: Mellanox Build Bot
Community-CI: Broadcom CI <spdk-ci.pdl@broadcom.com>
parent 8bbc7b69
Loading
Loading
Loading
Loading
+6 −1
Original line number Diff line number Diff line
@@ -5585,6 +5585,7 @@ free_nvme_async_probe_ctx(struct nvme_async_probe_ctx *ctx)
	spdk_keyring_put_key(ctx->drv_opts.tls_psk);
	spdk_keyring_put_key(ctx->drv_opts.dhchap_key);
	spdk_keyring_put_key(ctx->drv_opts.dhchap_ctrlr_key);
	free(ctx->base_name);
	free(ctx);
}

@@ -6671,7 +6672,11 @@ spdk_bdev_nvme_create(struct spdk_nvme_transport_id *trid,
	if (!ctx) {
		return -ENOMEM;
	}
	ctx->base_name = base_name;
	ctx->base_name = strdup(base_name);
	if (!ctx->base_name) {
		free(ctx);
		return -ENOMEM;
	}
	ctx->names = names;
	ctx->max_bdevs = count;
	ctx->cb_fn = cb_fn;
+1 −1
Original line number Diff line number Diff line
@@ -29,7 +29,7 @@ typedef void (*spdk_bdev_nvme_stop_discovery_fn)(void *ctx);

struct nvme_async_probe_ctx {
	struct spdk_nvme_probe_ctx *probe_ctx;
	const char *base_name;
	char *base_name;
	const char **names;
	uint32_t max_bdevs;
	uint32_t reported_bdevs;