From patchwork Mon Jul 26 16:47:49 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arkadiusz Kusztal X-Patchwork-Id: 96297 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 64E7DA0C47; Mon, 26 Jul 2021 18:47:59 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id EDEC9410EA; Mon, 26 Jul 2021 18:47:58 +0200 (CEST) Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by mails.dpdk.org (Postfix) with ESMTP id 1EB8A410E6 for ; Mon, 26 Jul 2021 18:47:56 +0200 (CEST) X-IronPort-AV: E=McAfee;i="6200,9189,10057"; a="297849811" X-IronPort-AV: E=Sophos;i="5.84,270,1620716400"; d="scan'208";a="297849811" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Jul 2021 09:47:55 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.84,270,1620716400"; d="scan'208";a="664731183" Received: from silpixa00400308.ir.intel.com ([10.237.214.190]) by fmsmga005.fm.intel.com with ESMTP; 26 Jul 2021 09:47:53 -0700 From: Arek Kusztal To: dev@dpdk.org Cc: gakhil@marvell.com, fiona.trahe@intel.com, roy.fan.zhang@intel.com, Arek Kusztal Date: Mon, 26 Jul 2021 17:47:49 +0100 Message-Id: <20210726164749.10878-1-arkadiuszx.kusztal@intel.com> X-Mailer: git-send-email 2.17.1 Subject: [dpdk-dev] [PATCH] crypto/qat: fix illegal access of an array 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" Fix possible access of an array by negative index in function qat_sym_qp_setup. Fixes: 8f393c4ffdc1 ("common/qat: support GEN4 devices") Coverity issue: 372131 Coverity issue: 372134 Signed-off-by: Arek Kusztal Acked-by: Adam Dybkowski --- drivers/crypto/qat/qat_sym_pmd.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/drivers/crypto/qat/qat_sym_pmd.c b/drivers/crypto/qat/qat_sym_pmd.c index 1c7b142511..6868e5f001 100644 --- a/drivers/crypto/qat/qat_sym_pmd.c +++ b/drivers/crypto/qat/qat_sym_pmd.c @@ -176,16 +176,17 @@ static int qat_sym_qp_setup(struct rte_cryptodev *dev, uint16_t qp_id, int ring_pair = qat_select_valid_queue(qat_dev, qp_id, QAT_SERVICE_SYMMETRIC); - sym_hw_qps = - &qat_dev->qp_gen4_data[0][0]; - qp_hw_data = - &qat_dev->qp_gen4_data[ring_pair][0]; + if (ring_pair < 0) { QAT_LOG(ERR, "qp_id %u invalid for this device, no enough services allocated for GEN4 device", qp_id); return -EINVAL; } + sym_hw_qps = + &qat_dev->qp_gen4_data[0][0]; + qp_hw_data = + &qat_dev->qp_gen4_data[ring_pair][0]; } else { sym_hw_qps = qat_gen_config[qat_dev->qat_dev_gen] .qp_hw_data[QAT_SERVICE_SYMMETRIC];