Skip to content

Commit

Permalink
driver: crypto: hisilicon: fix excepton handling
Browse files Browse the repository at this point in the history
1. support num = 0 in qm_set_vt_common().
2. release qp when qm_xqc_cfg() failed.
3. add check of msg and qp->num in hisi_qp_recv_sync().

Signed-off-by: Zexi Yu <yuzexi@hisilicon.com>
  • Loading branch information
yuzexiyzx committed Jan 29, 2024
1 parent d557d17 commit 094ae74
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions core/drivers/crypto/hisilicon/hisi_qm.c
Original file line number Diff line number Diff line change
Expand Up @@ -322,11 +322,6 @@ static enum hisi_drv_status qm_set_xqc_vft(struct hisi_qm *qm,
enum hisi_drv_status ret = HISI_QM_DRVCRYPT_NO_ERR;
int i = 0;

if (!num) {
EMSG("Invalid sq num");
return HISI_QM_DRVCRYPT_EINVAL;
}

for (i = QM_SQC_VFT; i <= QM_CQC_VFT; i++) {
ret = qm_set_vft_common(qm, i, function, base, num);
if (ret) {
Expand Down Expand Up @@ -736,18 +731,20 @@ struct hisi_qp *hisi_qm_create_qp(struct hisi_qm *qm, uint8_t sq_type)

if (qm_sqc_cfg(qp)) {
EMSG("Fail to set qp[%"PRIu32"] sqc", qp->qp_id);
goto err_proc;
goto qp_release;
}

if (qm_cqc_cfg(qp)) {
EMSG("Fail to set qp[%"PRIu32"] cqc", qp->qp_id);
goto err_proc;
goto qp_release;
}

qm->qp_in_used++;
mutex_unlock(&qm->qp_lock);
return qp;

qp_release:
qp->used = false;
err_proc:
qp->sq_type = 0;
qp->cqc_phase = false;
Expand Down Expand Up @@ -875,8 +872,8 @@ enum hisi_drv_status hisi_qp_recv_sync(struct hisi_qp *qp, void *msg)
enum hisi_drv_status ret = HISI_QM_DRVCRYPT_NO_ERR;
uint32_t timeout = 0;

if (!qp) {
EMSG("QP is NULL");
if (!qp || !qp->qm || !msg) {
EMSG("Invalid qp recv sync parameters");
return HISI_QM_DRVCRYPT_EINVAL;
}

Expand Down

0 comments on commit 094ae74

Please sign in to comment.