Skip to content

Commit

Permalink
driver: crypto: hisilicon: fix exception handling
Browse files Browse the repository at this point in the history
When qm_set_vft_common() fails to configure, qm_set_xqc_vft() is
called with the num argument as zero to disable the device. Update
qm_set_xqc_vft() to handle this error path.

Signed-off-by: Zexi Yu <yuzexi@hisilicon.com>
  • Loading branch information
yuzexiyzx committed Feb 4, 2024
1 parent d557d17 commit 7e5f503
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 err_qp_release;
}

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

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

err_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 7e5f503

Please sign in to comment.