Skip to content

Commit a3bece3

Browse files
lin755gregkh
authored andcommitted
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: 015d239 ("uacce: add uacce driver") Cc: stable@vger.kernel.org Signed-off-by: Wenkai Lin <linwenkai6@hisilicon.com> Signed-off-by: Chenghai Huang <huangchenghai2@huawei.com> Acked-by: Zhangfei Gao <zhangfei.gao@linaro.org> Link: https://patch.msgid.link/20251202061256.4158641-2-huangchenghai2@huawei.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent bba7fd1 commit a3bece3

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

drivers/misc/uacce/uacce.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -519,6 +519,8 @@ EXPORT_SYMBOL_GPL(uacce_alloc);
519519
*/
520520
int uacce_register(struct uacce_device *uacce)
521521
{
522+
int ret;
523+
522524
if (!uacce)
523525
return -ENODEV;
524526

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

532-
return cdev_device_add(uacce->cdev, &uacce->dev);
534+
ret = cdev_device_add(uacce->cdev, &uacce->dev);
535+
if (ret)
536+
uacce->cdev = NULL;
537+
538+
return ret;
533539
}
534540
EXPORT_SYMBOL_GPL(uacce_register);
535541

0 commit comments

Comments
 (0)