crypto/qat: fix array access

Fix possible access of an array by negative index in function
qat_sym_qp_setup.

Coverity issue: 372131, 372134
Fixes: 8f393c4ffdc1 ("common/qat: support GEN4 devices")

Signed-off-by: Arek Kusztal <arkadiuszx.kusztal@intel.com>
Acked-by: Adam Dybkowski <adamx.dybkowski@intel.com>
This commit is contained in:
Arek Kusztal 2021-07-26 17:47:49 +01:00 committed by Akhil Goyal
parent 8cd5064c46
commit 92a3ea2244

View File

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