diff mbox series

crypto/qat: fix illegal access of an array

Message ID 20210726164749.10878-1-arkadiuszx.kusztal@intel.com (mailing list archive)
State Accepted, archived
Delegated to: akhil goyal
Headers show
Series crypto/qat: fix illegal access of an array | expand

Checks

Context Check Description
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-testing success Testing PASS
ci/iol-abi-testing success Testing PASS
ci/intel-Testing success Testing PASS
ci/Intel-compilation success Compilation OK
ci/github-robot success github build: passed
ci/checkpatch success coding style OK

Commit Message

Arek Kusztal July 26, 2021, 4:47 p.m. UTC
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 <arkadiuszx.kusztal@intel.com>
---
 drivers/crypto/qat/qat_sym_pmd.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

Comments

Dybkowski, AdamX July 27, 2021, 9:31 a.m. UTC | #1
> -----Original Message-----
> From: dev <dev-bounces@dpdk.org> On Behalf Of Arek Kusztal
> Sent: Monday, 26 July, 2021 18:48
> To: dev@dpdk.org
> Cc: gakhil@marvell.com; Trahe, Fiona <fiona.trahe@intel.com>; Zhang, Roy
> Fan <roy.fan.zhang@intel.com>; Kusztal, ArkadiuszX
> <arkadiuszx.kusztal@intel.com>
> Subject: [dpdk-dev] [PATCH] crypto/qat: fix illegal access of an array
> 
> 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 <arkadiuszx.kusztal@intel.com>

Acked-by: Adam Dybkowski <adamx.dybkowski@intel.com>
Akhil Goyal July 27, 2021, 5:36 p.m. UTC | #2
> > 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 <arkadiuszx.kusztal@intel.com>
> 
> Acked-by: Adam Dybkowski <adamx.dybkowski@intel.com>
Applied to dpdk-next-crypto
diff mbox series

Patch

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];