driver inclusion category: bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/I7C6LD CVE: NA
----------------------------------------------------------------------
Before removing the driver, flush all function communication tasks, and does not handle subsequent communication interruptions to prevent communication threads access released address.
Fixes: 46fdbecf7d61 ("crypto: hisilicon/qm - enable PF and VFs communication") Signed-off-by: Weili Qian qianweili@huawei.com Signed-off-by: JiangShui Yang yangjiangshui@h-partners.com --- drivers/crypto/hisilicon/qm.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-)
diff --git a/drivers/crypto/hisilicon/qm.c b/drivers/crypto/hisilicon/qm.c index 100c0afbcd4c..3cc9ccedb386 100644 --- a/drivers/crypto/hisilicon/qm.c +++ b/drivers/crypto/hisilicon/qm.c @@ -206,7 +206,6 @@ #define WAIT_PERIOD 20 #define REMOVE_WAIT_DELAY 10
-#define QM_DRIVER_REMOVING 0 #define QM_QOS_PARAM_NUM 2 #define QM_QOS_MAX_VAL 1000 #define QM_QOS_RATE 100 @@ -1115,6 +1114,11 @@ static irqreturn_t qm_mb_cmd_irq(int irq, void *data) if (!val) return IRQ_NONE;
+ if (test_bit(QM_DRIVER_DOWN, &qm->misc_ctl)) { + dev_warn(&qm->pdev->dev, "Driver is down, message cannot be processed!\n"); + return IRQ_HANDLED; + } + schedule_work(&qm->cmd_process);
return IRQ_HANDLED; @@ -2826,7 +2830,7 @@ EXPORT_SYMBOL_GPL(qm_register_uacce); */ static int qm_frozen(struct hisi_qm *qm) { - if (test_bit(QM_DRIVER_REMOVING, &qm->misc_ctl)) + if (test_bit(QM_DRIVER_DOWN, &qm->misc_ctl)) return 0;
down_write(&qm->qps_lock); @@ -2834,7 +2838,7 @@ static int qm_frozen(struct hisi_qm *qm) if (!qm->qp_in_used) { qm->qp_in_used = qm->qp_num; up_write(&qm->qps_lock); - set_bit(QM_DRIVER_REMOVING, &qm->misc_ctl); + set_bit(QM_DRIVER_DOWN, &qm->misc_ctl); return 0; }
@@ -2891,6 +2895,9 @@ void hisi_qm_wait_task_finish(struct hisi_qm *qm, struct hisi_qm_list *qm_list) test_bit(QM_RESETTING, &qm->misc_ctl)) msleep(WAIT_PERIOD);
+ if (test_bit(QM_SUPPORT_MB_COMMAND, &qm->caps)) + flush_work(&qm->cmd_process); + udelay(REMOVE_WAIT_DELAY); } EXPORT_SYMBOL_GPL(hisi_qm_wait_task_finish); @@ -4775,7 +4782,7 @@ static irqreturn_t qm_abnormal_irq(int irq, void *data) atomic64_inc(&qm->debug.dfx.abnormal_irq_cnt); ret = qm_process_dev_error(qm); if (ret == ACC_ERR_NEED_RESET && - !test_bit(QM_DRIVER_REMOVING, &qm->misc_ctl) && + !test_bit(QM_DRIVER_DOWN, &qm->misc_ctl) && !test_and_set_bit(QM_RST_SCHED, &qm->misc_ctl)) schedule_work(&qm->rst_work);