Commit 3cbc9908 authored by Yang Shen's avatar Yang Shen Committed by JangShui Yang
Browse files

crypto: hisilicon_qm - fix the uacce_alloc return value check

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: 9e00df71 ("crypto: hisilicon - register zip engine to uacce")
Signed-off-by: default avatarYang Shen <shenyang39@huawei.com>
Signed-off-by: default avatarJiangShui Yang <yangjiangshui@h-partners.com>
parent 2ab62c81
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -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);