Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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: 015d239ac014 ("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>

authored by

Wenkai Lin and committed by
Greg Kroah-Hartman
a3bece36 bba7fd12

+7 -1
+7 -1
drivers/misc/uacce/uacce.c
··· 519 519 */ 520 520 int uacce_register(struct uacce_device *uacce) 521 521 { 522 + int ret; 523 + 522 524 if (!uacce) 523 525 return -ENODEV; 524 526 ··· 531 529 uacce->cdev->ops = &uacce_fops; 532 530 uacce->cdev->owner = THIS_MODULE; 533 531 534 - return cdev_device_add(uacce->cdev, &uacce->dev); 532 + ret = cdev_device_add(uacce->cdev, &uacce->dev); 533 + if (ret) 534 + uacce->cdev = NULL; 535 + 536 + return ret; 535 537 } 536 538 EXPORT_SYMBOL_GPL(uacce_register); 537 539