diff --git a/lib/nvme/nvme_tcp.c b/lib/nvme/nvme_tcp.c index 25840b7b6..b1e892468 100644 --- a/lib/nvme/nvme_tcp.c +++ b/lib/nvme/nvme_tcp.c @@ -402,7 +402,7 @@ nvme_tcp_qpair_process_send_queue(struct nvme_tcp_qpair *tqpair) * Build up a list of iovecs for the first few PDUs in the * tqpair 's send_queue. */ - while (pdu != NULL && ((array_size - iovcnt) >= 3)) { + while (pdu != NULL && ((array_size - iovcnt) >= (2 + (int)pdu->data_iovcnt))) { iovcnt += nvme_tcp_build_iovs(&iovs[iovcnt], array_size - iovcnt, pdu, tqpair->host_hdgst_enable, tqpair->host_ddgst_enable, &mapped_length); diff --git a/lib/nvmf/tcp.c b/lib/nvmf/tcp.c index 8afb81aa7..905598b2c 100644 --- a/lib/nvmf/tcp.c +++ b/lib/nvmf/tcp.c @@ -782,7 +782,7 @@ spdk_nvmf_tcp_qpair_flush_pdus_internal(struct spdk_nvmf_tcp_qpair *tqpair) int iovcnt = 0; int bytes = 0; int total_length = 0; - uint32_t mapped_length; + uint32_t mapped_length = 0; struct nvme_tcp_pdu *pdu; int pdu_length; TAILQ_HEAD(, nvme_tcp_pdu) completed_pdus_list; @@ -797,7 +797,7 @@ spdk_nvmf_tcp_qpair_flush_pdus_internal(struct spdk_nvmf_tcp_qpair *tqpair) * Build up a list of iovecs for the first few PDUs in the * tqpair 's send_queue. */ - while (pdu != NULL && ((array_size - iovcnt) >= 3)) { + while (pdu != NULL && ((array_size - iovcnt) >= (2 + (int)pdu->data_iovcnt))) { iovcnt += nvme_tcp_build_iovs(&iovs[iovcnt], array_size - iovcnt, pdu,