driver inclusion category: bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/IB9H0P CVE: NA
----------------------------------------------------------------------
The uacce_alloc mentions that caller needs check returned negotiated uacce->flags. And now it will clear the bit UACCE_DEV_SVA if failed to enable sva. So the qm need to remove uacce if 'flags' changes.
Fixes: 9e00df7156e4 ("crypto: hisilicon - register zip engine to uacce") Signed-off-by: Yang Shen shenyang39@huawei.com Signed-off-by: JiangShui Yang yangjiangshui@h-partners.com --- drivers/crypto/hisilicon/qm.c | 8 ++++++++ 1 file changed, 8 insertions(+)
diff --git a/drivers/crypto/hisilicon/qm.c b/drivers/crypto/hisilicon/qm.c index f5d9ff496005..b3bd4aece611 100644 --- a/drivers/crypto/hisilicon/qm.c +++ b/drivers/crypto/hisilicon/qm.c @@ -2786,6 +2786,7 @@ static int qm_alloc_uacce(struct hisi_qm *qm) struct uacce_interface interface = {0}; struct pci_dev *pdev = qm->pdev; struct uacce_device *uacce; + u32 flags; int ret;
ret = strscpy(interface.name, dev_driver_string(&pdev->dev), @@ -2804,11 +2805,18 @@ static int qm_alloc_uacce(struct hisi_qm *qm) }
interface.ops = &uacce_qm_ops; + flags = interface.flags; uacce = uacce_alloc(&pdev->dev, &interface); if (IS_ERR(uacce)) { pci_err(pdev, "fail to alloc uacce device\n!"); return PTR_ERR(uacce); } + if (flags != interface.flags) { + pci_err(pdev, "fail to enable sva\n!"); + uacce_remove(uacce); + return -EINVAL; + } + qm->uacce = uacce;
qm_uacce_base_init(qm);