From patchwork Fri Jan 22 13:35:23 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ankur Dwivedi X-Patchwork-Id: 87094 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 BAABEA0A0A; Fri, 22 Jan 2021 14:35:38 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 8070F140FBA; Fri, 22 Jan 2021 14:35:38 +0100 (CET) Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by mails.dpdk.org (Postfix) with ESMTP id 5CA22140FB4 for ; Fri, 22 Jan 2021 14:35:37 +0100 (CET) Received: from pps.filterd (m0045849.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 10MDZ3Cl004000; Fri, 22 Jan 2021 05:35:36 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : mime-version : content-transfer-encoding : content-type; s=pfpt0220; bh=qbLqwOXldv1lBJIYO8KgsBHFa4vwvmhlZpYS6zbhKPQ=; b=LzFzdO5c1dkpA43X9585WaH6y8fhDVbym11ngEc/8So9Jk4nRMY7JV4gqkSTAvdp/Y4H WDXIMpOyy2y0Fzgq4vWAgD4PExUCiUGP5lB3YffVXTEEm5TqbDZR8zTmsBsblMKK1Sqi 4o32t+ExRz2aihS5Cp6sHa7RChXEsLhevIZmXP3BGobYCMv+4bMen5GMlINE9GzSyMCm OcuDHr2yHLz2qqWxFzHNYy8btzWc/mCddycj6JWSfeTmsziR5aOhT5sdWN2nOWa7dVW3 eB6uYEakRO6OqwLNvqbST2ZUYes5ub43GVjLrM7O+jNxbw5EhMudCn3GQT8bD5vur8JD 7Q== Received: from dc5-exch01.marvell.com ([199.233.59.181]) by mx0a-0016f401.pphosted.com with ESMTP id 3668p31yjy-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Fri, 22 Jan 2021 05:35:36 -0800 Received: from SC-EXCH02.marvell.com (10.93.176.82) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Fri, 22 Jan 2021 05:35:34 -0800 Received: from DC5-EXCH01.marvell.com (10.69.176.38) by SC-EXCH02.marvell.com (10.93.176.82) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Fri, 22 Jan 2021 05:35:34 -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; Fri, 22 Jan 2021 05:35:34 -0800 Received: from hyd1349.t110.caveonetworks.com.com (unknown [10.29.45.13]) by maili.marvell.com (Postfix) with ESMTP id A5E9C3F7040; Fri, 22 Jan 2021 05:35:32 -0800 (PST) From: Ankur Dwivedi To: CC: , , , Ankur Dwivedi Date: Fri, 22 Jan 2021 19:05:23 +0530 Message-ID: <20210122133523.22507-1-adwivedi@marvell.com> X-Mailer: git-send-email 2.28.0 MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.343, 18.0.737 definitions=2021-01-22_09:2021-01-21, 2021-01-22 signatures=0 Subject: [dpdk-dev] [PATCH] 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: 1c119d38876d ("crypto/octeontx2: support lookaside AES-CBC SHA1-HMAC") Signed-off-by: Ankur Dwivedi --- 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 89ed7cbd25..342f089df8 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 |