Commit a3bece36 authored by Wenkai Lin's avatar Wenkai Lin Committed by Greg Kroah-Hartman
Browse files

uacce: fix cdev handling in the cleanup path



When cdev_device_add fails, it internally releases the cdev memory,
and if cdev_device_del is then executed, it will cause a hang error.
To fix it, we check the return value of cdev_device_add() and clear
uacce->cdev to avoid calling cdev_device_del in the uacce_remove.

Fixes: 015d239a ("uacce: add uacce driver")
Cc: stable@vger.kernel.org
Signed-off-by: default avatarWenkai Lin <linwenkai6@hisilicon.com>
Signed-off-by: default avatarChenghai Huang <huangchenghai2@huawei.com>
Acked-by: default avatarZhangfei Gao <zhangfei.gao@linaro.org>
Link: https://patch.msgid.link/20251202061256.4158641-2-huangchenghai2@huawei.com


Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent bba7fd12
Loading
Loading
Loading
Loading
+7 −1
Original line number Diff line number Diff line
@@ -519,6 +519,8 @@ EXPORT_SYMBOL_GPL(uacce_alloc);
 */
int uacce_register(struct uacce_device *uacce)
{
	int ret;

	if (!uacce)
		return -ENODEV;

@@ -529,7 +531,11 @@ int uacce_register(struct uacce_device *uacce)
	uacce->cdev->ops = &uacce_fops;
	uacce->cdev->owner = THIS_MODULE;

	return cdev_device_add(uacce->cdev, &uacce->dev);
	ret = cdev_device_add(uacce->cdev, &uacce->dev);
	if (ret)
		uacce->cdev = NULL;

	return ret;
}
EXPORT_SYMBOL_GPL(uacce_register);