From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id E3AE2A04FA; Wed, 5 Feb 2020 14:17:27 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 2E0A01C1E8; Wed, 5 Feb 2020 14:16:58 +0100 (CET) Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by dpdk.org (Postfix) with ESMTP id 8D7571C1D8 for ; Wed, 5 Feb 2020 14:16:56 +0100 (CET) Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 015DDuuh025994; Wed, 5 Feb 2020 05:16:56 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=pfpt0818; bh=exZ7qWfV5GZ8BPS/K4WXD8jjnDuARG9mS9olguLkZ98=; b=OHyYYjoSrI/QamgZ1gi/Nfpaz0y0RM5RNkfU0tY0DIU/IAvVsbsyeK9EKBn8TAa3Wvg1 34N0LkS39qL0cptZD6R2v+wWX8cX+IHyNExo7DmXr/5kGFlHneqDOUpt/QKUCwb9Tm0M xctfXr4pjuiqgE+L2ekkDNuWuBu/3E1OzmV60J3i7Vz82U1YNWFUnu/Sj/pORHxmhUyH 98c6OkHEDsNvv4NAzPXKnb1rhk9z6M657okWemC9kemAIMkQRVCT0WSZsGWLKLQrHtqk +gXWUrIWP9Q2bJIw+cEwvg92n9vIGNYR0IwVckLnBI2ycK5duIGssIy968ECjxADmCOi Ng== Received: from sc-exch01.marvell.com ([199.233.58.181]) by mx0b-0016f401.pphosted.com with ESMTP id 2xyhn12wwh-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Wed, 05 Feb 2020 05:16:55 -0800 Received: from SC-EXCH02.marvell.com (10.93.176.82) by SC-EXCH01.marvell.com (10.93.176.81) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Wed, 5 Feb 2020 05:16:53 -0800 Received: from maili.marvell.com (10.93.176.43) by SC-EXCH02.marvell.com (10.93.176.82) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Wed, 5 Feb 2020 05:16:53 -0800 Received: from ajoseph83.caveonetworks.com (unknown [10.29.45.60]) by maili.marvell.com (Postfix) with ESMTP id 6A7463F72F1; Wed, 5 Feb 2020 05:16:52 -0800 (PST) From: Anoob Joseph To: Akhil Goyal CC: Archana Muniganti , , Anoob Joseph Date: Wed, 5 Feb 2020 18:46:17 +0530 Message-ID: <1580908578-3384-6-git-send-email-anoobj@marvell.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1580908578-3384-1-git-send-email-anoobj@marvell.com> References: <1580908578-3384-1-git-send-email-anoobj@marvell.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.138, 18.0.572 definitions=2020-02-05_03:2020-02-04, 2020-02-05 signatures=0 Subject: [dpdk-dev] [PATCH 5/6] common/cpt: fix fill_sg_comp api for zero datalen X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" From: Archana Muniganti fill_sg_comp_from_iov() prepares gather components for i/p IOV buffers and extra buf. This API is failing to create a gather component for extra_buf when IOV buf len is zero. Though there is enough space to accommodate extra_buf, because of pre-decrementing of extra_buf length from aggregate size, this issue is seen. Fixes: b74652f3a91f ("common/cpt: add microcode interface for encryption") Signed-off-by: Archana Muniganti Signed-off-by: Anoob Joseph --- drivers/common/cpt/cpt_ucode.h | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/drivers/common/cpt/cpt_ucode.h b/drivers/common/cpt/cpt_ucode.h index 081249c..c310ea7 100644 --- a/drivers/common/cpt/cpt_ucode.h +++ b/drivers/common/cpt/cpt_ucode.h @@ -373,7 +373,7 @@ fill_sg_comp_from_iov(sg_comp_t *list, { int32_t j; uint32_t extra_len = extra_buf ? extra_buf->size : 0; - uint32_t size = *psize - extra_len; + uint32_t size = *psize; buf_ptr_t *bufs; bufs = from->bufs; @@ -382,9 +382,6 @@ fill_sg_comp_from_iov(sg_comp_t *list, uint32_t e_len; sg_comp_t *to = &list[i >> 2]; - if (!bufs[j].size) - continue; - if (unlikely(from_offset)) { if (from_offset >= bufs[j].size) { from_offset -= bufs[j].size; @@ -416,18 +413,19 @@ fill_sg_comp_from_iov(sg_comp_t *list, to->u.s.len[i % 4] = rte_cpu_to_be_16(e_len); } + extra_len = RTE_MIN(extra_len, size); /* Insert extra data ptr */ if (extra_len) { i++; to = &list[i >> 2]; to->u.s.len[i % 4] = - rte_cpu_to_be_16(extra_buf->size); + rte_cpu_to_be_16(extra_len); to->ptr[i % 4] = rte_cpu_to_be_64(extra_buf->dma_addr); - - /* size already decremented by extra len */ + size -= extra_len; } + next_len = RTE_MIN(next_len, size); /* insert the rest of the data */ if (next_len) { i++; -- 2.7.4