Received: by 2002:a19:771d:0:0:0:0:0 with SMTP id s29csp1265683lfc; Wed, 1 Jun 2022 13:33:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwwLl3nQxhIoLkWKOycXwbvuW3ECuWr53xgfx9qMhChBHm+S0ZirSVd7bSY6ZOexQKOsmUn X-Received: by 2002:a05:6a00:10cc:b0:4fe:3f1c:2d1 with SMTP id d12-20020a056a0010cc00b004fe3f1c02d1mr68743801pfu.0.1654115638678; Wed, 01 Jun 2022 13:33:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654115638; cv=none; d=google.com; s=arc-20160816; b=X/ti4KVw6QEVMyIwi6zlwSoRyfLse25iTXhm5qRGd2WmF7EkhjMBvWDxA+ZIoCjrm7 EublmTERBOpj2S4XIXNI7P2lNJJZkGHaqIsCTHGWj3GtBBfPXb+vLoNRpPTquoueGMJt odMrkYH/kV97P10Sr/4oXI7rkqiqYL4bH/1tnCAOK7EVHt3fR1NxdHPA9AYohBG6tRlC ifSPHJDwDZPfSOPBR0WSeYCoSJP8BXiBm50PajHVAxnxD1UFYt9js2BQmIm34EDZSbBn DJrsvcdWQa3lYdKuNe9T7LmhREhzJzpO4pZgWRv8C1AAlRxmhQInLkqTxLm47Fk/HduA FWZQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=sQSNY7RRz2Ap5IH2BMIUKIP53aA2GrvaUEc+gCJvoic=; b=kJS73nBRT3FgWeG6h067ndmPWZUoDmCEcm90ZibI/1NOXcCsTZSADXiBKiQvC+s5Bf xDf8GovQ8VstPiqAPeq4DkdPt2kTDFZsDPdO+RpT7azCWZkuEYh9kpeCjmHrXjlW4ySg qlBxQqdty5ndBHV5MI7ZVgf2a1Aw0Xlbmu3GkZgTGPtvIzCEW44UvbTVEQMPaHe0iMLs cCEqflK05BDVAS1x5sLlQ/EYY3YHKY2SVjTcNTiK41zNPlyBUYSaGYgFAKhXzxh8wXQG 1MYnRSJCeFaVjbWDjpkpmFeK6cKySB4vqLsjf/ZCdhHdivD+fq6/+VGbLbZ4676uLeco YGLQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@marvell.com header.s=pfpt0220 header.b=UkYTrhtn; spf=softfail (google.com: domain of transitioning linux-crypto-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=REJECT dis=NONE) header.from=marvell.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id f64-20020a62db43000000b0051897ee8630si3118554pfg.297.2022.06.01.13.33.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Jun 2022 13:33:58 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-crypto-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@marvell.com header.s=pfpt0220 header.b=UkYTrhtn; spf=softfail (google.com: domain of transitioning linux-crypto-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=REJECT dis=NONE) header.from=marvell.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id CA5341E1740; Wed, 1 Jun 2022 12:43:37 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1349053AbiFAIKy (ORCPT + 99 others); Wed, 1 Jun 2022 04:10:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58182 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1350574AbiFAIJ6 (ORCPT ); Wed, 1 Jun 2022 04:09:58 -0400 Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CD04356436; Wed, 1 Jun 2022 01:09:57 -0700 (PDT) Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 24VMJRSr007355; Wed, 1 Jun 2022 01:09:37 -0700 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=sQSNY7RRz2Ap5IH2BMIUKIP53aA2GrvaUEc+gCJvoic=; b=UkYTrhtnLNGcf3Pa0WqEllPq4mMvPTzIfU3kpUF8LQChlbboiVMwxCjYk74cP75fSS+c KEAmMy+ykFp4C8BDwuoo3gXpdCDtBGTY98aX1ogcJ+c8MoKGK9HfDxNDuSSVqu7ABuf1 cUxzu0yvqzPVnapzB1KE7qra3f9p4FFgBkZWipzbrpblhBtxYu1iIBB4iICRa/9BvX/S /dRC0h88zFhLNO3UlRwdSSq8BWaF4zDw60TqyPwMfA7SpwhwRVUz2vJ6I4K+sASZoX+h SrUVs0IkgJaRPvwewaqLTRwQ4UuIoV5n4UOLVnlMe87BQSg78s7jZ03Ce9bxdt01beyV 8w== Received: from dc5-exch02.marvell.com ([199.233.59.182]) by mx0b-0016f401.pphosted.com (PPS) with ESMTPS id 3gbk8nd8yy-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Wed, 01 Jun 2022 01:09:37 -0700 Received: from DC5-EXCH02.marvell.com (10.69.176.39) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Wed, 1 Jun 2022 01:09:35 -0700 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server id 15.0.1497.18 via Frontend Transport; Wed, 1 Jun 2022 01:09:35 -0700 Received: from localhost.localdomain (unknown [10.28.34.29]) by maili.marvell.com (Postfix) with ESMTP id C36AE3F7079; Wed, 1 Jun 2022 01:09:31 -0700 (PDT) From: Shijith Thotton To: Arnaud Ebalard , Herbert Xu , Boris Brezillon , "Dan Carpenter" CC: Shijith Thotton , , , , Srujana Challa , "David S. Miller" , Jiapeng Chong , Kees Cook , "open list" Subject: [PATCH v2] crypto: octeontx2: fix potential null pointer access Date: Wed, 1 Jun 2022 13:38:59 +0530 Message-ID: <6f772668877d2bd7dfdf7b45bb90cb56b3a6339b.1654070734.git.sthotton@marvell.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Proofpoint-ORIG-GUID: aWuB22d5fM_4GgWUb8rNdGK6mWi6wk53 X-Proofpoint-GUID: aWuB22d5fM_4GgWUb8rNdGK6mWi6wk53 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.874,Hydra:6.0.517,FMLib:17.11.64.514 definitions=2022-06-01_02,2022-05-30_03,2022-02-23_01 X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org Added missing checks to avoid null pointer dereference. The patch fixes below issue reported by klocwork tool: . Pointer 'strsep( &val, ":" )' returned from call to function 'strsep' at line 1608 may be NULL and will be dereferenced at line 1608. Also there are 2 similar errors on lines 1620, 1632 in otx2_cptpf_ucode.c. Signed-off-by: Shijith Thotton --- v2: * Removed unwanted check for pcim_iomap_table. .../crypto/marvell/octeontx2/otx2_cptpf_ucode.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/drivers/crypto/marvell/octeontx2/otx2_cptpf_ucode.c b/drivers/crypto/marvell/octeontx2/otx2_cptpf_ucode.c index 9cba2f714c7e..080cbfa093ec 100644 --- a/drivers/crypto/marvell/octeontx2/otx2_cptpf_ucode.c +++ b/drivers/crypto/marvell/octeontx2/otx2_cptpf_ucode.c @@ -1605,7 +1605,10 @@ int otx2_cpt_dl_custom_egrp_create(struct otx2_cptpf_dev *cptpf, if (!strncasecmp(val, "se", 2) && strchr(val, ':')) { if (has_se || ucode_idx) goto err_print; - tmp = strim(strsep(&val, ":")); + tmp = strsep(&val, ":"); + if (!tmp) + goto err_print; + tmp = strim(tmp); if (!val) goto err_print; if (strlen(tmp) != 2) @@ -1617,7 +1620,10 @@ int otx2_cpt_dl_custom_egrp_create(struct otx2_cptpf_dev *cptpf, } else if (!strncasecmp(val, "ae", 2) && strchr(val, ':')) { if (has_ae || ucode_idx) goto err_print; - tmp = strim(strsep(&val, ":")); + tmp = strsep(&val, ":"); + if (!tmp) + goto err_print; + tmp = strim(tmp); if (!val) goto err_print; if (strlen(tmp) != 2) @@ -1629,7 +1635,10 @@ int otx2_cpt_dl_custom_egrp_create(struct otx2_cptpf_dev *cptpf, } else if (!strncasecmp(val, "ie", 2) && strchr(val, ':')) { if (has_ie || ucode_idx) goto err_print; - tmp = strim(strsep(&val, ":")); + tmp = strsep(&val, ":"); + if (!tmp) + goto err_print; + tmp = strim(tmp); if (!val) goto err_print; if (strlen(tmp) != 2) -- 2.25.1