From b4af31de928c2ea18346984d80c2679b78638b42 Mon Sep 17 00:00:00 2001 From: Ziye Yang Date: Wed, 16 Jun 2021 18:21:00 +0800 Subject: [PATCH] nvmf/tcp: fix the unexpected pointer access from mgmt_pdu Because we use spdk_dma_malloc, then it does not init the the contents in the memory. Fixes #1996 Change-Id: Ieef411f6ae5114de9f732df6096e0bb123efb7e0 Signed-off-by: Ziye Yang Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/8374 Reviewed-by: Changpeng Liu Reviewed-by: Aleksey Marchuk Reviewed-by: GangCao Tested-by: SPDK CI Jenkins Community-CI: Mellanox Build Bot --- lib/nvmf/tcp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/nvmf/tcp.c b/lib/nvmf/tcp.c index b1694a7c8..1ec720a6f 100644 --- a/lib/nvmf/tcp.c +++ b/lib/nvmf/tcp.c @@ -946,7 +946,7 @@ nvmf_tcp_qpair_init_mem_resource(struct spdk_nvmf_tcp_qpair *tqpair) } /* Add addtional 2 members, which will be used for mgmt_pdu and pdu_in_progress owned by the tqpair */ - tqpair->pdus = spdk_dma_malloc((tqpair->resource_count + 2) * sizeof(*tqpair->pdus), 0x1000, NULL); + tqpair->pdus = spdk_dma_zmalloc((tqpair->resource_count + 2) * sizeof(*tqpair->pdus), 0x1000, NULL); if (!tqpair->pdus) { SPDK_ERRLOG("Unable to allocate pdu pool on tqpair =%p.\n", tqpair); return -1;