bdev/nvme: Alloc bdev name array dynamically for attach_controller RPC

Signed-off-by: Shuhei Matsumoto <smatsumoto@nvidia.com>
Change-Id: I9c1822421563210f6a656553355e29e75c8b0c21
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/17650
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Aleksey Marchuk <alexeymar@nvidia.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
This commit is contained in:
Shuhei Matsumoto 2023-04-20 11:35:25 +09:00 committed by Konrad Sztyber
parent d33d418742
commit f0a2538c04

View File

@ -265,7 +265,7 @@ struct rpc_bdev_nvme_attach_controller_ctx {
struct rpc_bdev_nvme_attach_controller req;
uint32_t count;
size_t bdev_count;
const char *names[NVME_MAX_BDEVS_PER_RPC];
const char **names;
struct spdk_jsonrpc_request *request;
};
@ -273,6 +273,7 @@ static void
free_rpc_bdev_nvme_attach_controller_ctx(struct rpc_bdev_nvme_attach_controller_ctx *ctx)
{
free_rpc_bdev_nvme_attach_controller(&ctx->req);
free(ctx->names);
free(ctx);
}
@ -345,6 +346,12 @@ rpc_bdev_nvme_attach_controller(struct spdk_jsonrpc_request *request,
goto cleanup;
}
ctx->names = calloc(NVME_MAX_BDEVS_PER_RPC, sizeof(char *));
if (ctx->names == NULL) {
spdk_jsonrpc_send_error_response(request, -ENOMEM, spdk_strerror(ENOMEM));
goto cleanup;
}
/* Parse trstring */
rc = spdk_nvme_transport_id_populate_trstring(&trid, ctx->req.trtype);
if (rc < 0) {