From patchwork Thu Jan 28 05:16:53 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ankur Dwivedi X-Patchwork-Id: 87456 X-Patchwork-Delegate: gakhil@marvell.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 5B988A09E4; Thu, 28 Jan 2021 06:17:15 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id CC4A7140CCF; Thu, 28 Jan 2021 06:17:14 +0100 (CET) Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by mails.dpdk.org (Postfix) with ESMTP id 3BD13140CCB for ; Thu, 28 Jan 2021 06:17:13 +0100 (CET) Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 10S5GGsH007806; Wed, 27 Jan 2021 21:17:12 -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=pfpt0220; bh=Hj72Z+2LSso7ZJtlMYHo9i0uC07Kn5WoyH+O6Wc/LtI=; b=Kl+fsQ11Iruf4bj3jITdpnObMQisnhpEMKTlvCY/YNTBrUjUhQIxxDW33XdPVhYHpDHY 7IKs3KpQyLMxUL7ipYg87wrfQ9+zoDKLkvTSOclcHWd2X3uE8JglcqfWF7XTX6O5Ps5A FsgsUl0kTBYk7vgalnSqcruD09Pqcq6+5P9PpT9HBj4V+Wncxp0CRgO3yKMJvoG0AtwZ JGWQ+Py/Eyf1ClsaF+b3ranbjhJQLX7RQrE9j8IH9DegVQbtR1Bu+WP5yDIF9MhrviCr 9YUUpw5E5Xk5l2lqLm0SIoAk4nkr9Ue8V4NsRbV/IcSKpJpGgvxC35ygJDfB3nHQ/XHu FA== Received: from dc5-exch01.marvell.com ([199.233.59.181]) by mx0b-0016f401.pphosted.com with ESMTP id 36b1xpkcb2-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Wed, 27 Jan 2021 21:17:12 -0800 Received: from DC5-EXCH01.marvell.com (10.69.176.38) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Wed, 27 Jan 2021 21:17:10 -0800 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Wed, 27 Jan 2021 21:17:09 -0800 Received: from hyd1349.t110.caveonetworks.com.com (unknown [10.29.45.13]) by maili.marvell.com (Postfix) with ESMTP id 5F6843F703F; Wed, 27 Jan 2021 21:17:08 -0800 (PST) From: Ankur Dwivedi To: CC: , , , Ankur Dwivedi Date: Thu, 28 Jan 2021 10:46:53 +0530 Message-ID: <20210128051653.20503-1-adwivedi@marvell.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20210122133523.22507-1-adwivedi@marvell.com> References: <20210122133523.22507-1-adwivedi@marvell.com> MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.343, 18.0.737 definitions=2021-01-28_01:2021-01-27, 2021-01-28 signatures=0 Subject: [dpdk-dev] [PATCH v2] crypto/octeontx2: fix null pointer dereferences X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 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" Coverity reports that pointers ip and ip6 may be dereferenced with null value. This patch fixes this. Coverity issue: 365549 Coverity issue: 365551 Fixes: 8f685ec2d545 ("crypto/octeontx2: support AES-CBC SHA1-HMAC") Signed-off-by: Ankur Dwivedi --- v2: * Fixed wrong fixes reference in commit message. drivers/crypto/octeontx2/otx2_cryptodev_sec.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/crypto/octeontx2/otx2_cryptodev_sec.c b/drivers/crypto/octeontx2/otx2_cryptodev_sec.c index 89ed7cbd2..342f089df 100644 --- a/drivers/crypto/octeontx2/otx2_cryptodev_sec.c +++ b/drivers/crypto/octeontx2/otx2_cryptodev_sec.c @@ -208,10 +208,10 @@ crypto_sec_ipsec_outb_session_create(struct rte_cryptodev *crypto_dev, struct otx2_ipsec_po_sa_ctl *ctl; int cipher_key_len, auth_key_len; struct otx2_ipsec_po_out_sa *sa; - struct rte_ipv6_hdr *ip6 = NULL; - struct rte_ipv4_hdr *ip = NULL; struct otx2_sec_session *sess; struct otx2_cpt_inst_s inst; + struct rte_ipv6_hdr *ip6; + struct rte_ipv4_hdr *ip; int ret, ctx_len; sess = get_sec_session_private_data(sec_sess); @@ -282,6 +282,8 @@ crypto_sec_ipsec_outb_session_create(struct rte_cryptodev *crypto_dev, sa->sha2.template.ip4); ctx_len = RTE_ALIGN_CEIL(ctx_len, 8); lp->ctx_len = ctx_len >> 3; + } else { + return -EINVAL; } ip->version_ihl = RTE_IPV4_VHL_DEF; ip->next_proto_id = IPPROTO_ESP; @@ -331,6 +333,8 @@ crypto_sec_ipsec_outb_session_create(struct rte_cryptodev *crypto_dev, sa->sha2.template.ip6); ctx_len = RTE_ALIGN_CEIL(ctx_len, 8); lp->ctx_len = ctx_len >> 3; + } else { + return -EINVAL; } ip6->vtc_flow = rte_cpu_to_be_32(0x60000000 |