From 0a33bda593ee207c9d5142ab06eb895faf04ae6b Mon Sep 17 00:00:00 2001 From: Liu Xiaodong Date: Tue, 12 Oct 2021 18:58:11 -0400 Subject: [PATCH] bdev_nvme_rpc: NULL check for multipath Pointer 'ctx->req.multipath' returned from call to function 'strdup' may be NULL. Reported by Klocwork. Change-Id: Id4a188ec5340f02c9bd0643db0acb03409dd5829 Signed-off-by: Liu Xiaodong Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/9843 Community-CI: Broadcom CI Community-CI: Mellanox Build Bot Tested-by: SPDK CI Jenkins Reviewed-by: GangCao Reviewed-by: Aleksey Marchuk Reviewed-by: Tomasz Zawadzki --- module/bdev/nvme/bdev_nvme_rpc.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/module/bdev/nvme/bdev_nvme_rpc.c b/module/bdev/nvme/bdev_nvme_rpc.c index a2aec616e..f7e492d06 100644 --- a/module/bdev/nvme/bdev_nvme_rpc.c +++ b/module/bdev/nvme/bdev_nvme_rpc.c @@ -398,6 +398,10 @@ rpc_bdev_nvme_attach_controller(struct spdk_jsonrpc_request *request, "it was used to add a failover path. This behavior will default to rejecting " "the request in the future. Specify the 'multipath' parameter to control the behavior"); ctx->req.multipath = strdup("failover"); + if (ctx->req.multipath == NULL) { + SPDK_ERRLOG("cannot allocate multipath failover string\n"); + goto cleanup; + } } opts = spdk_nvme_ctrlr_get_opts(ctrlr->ctrlr);