[PATCH] uacce: publish the device in uacce_register()

From: Changyul Lee

Date: Wed Nov 18 2026 - 20:59:42 EST


uacce_alloc() publishes the device in uacce_xa before initialization
is complete. If a minor is reused, open() can find the new device
before its queue list, mutex, or driver-private data is ready.

Reserve the minor in uacce_alloc() and publish the device in
uacce_register(), after initialization. Until then, xa_load() returns
NULL and open() returns -ENODEV.

Fixes: 015d239ac014 ("uacce: add uacce driver")
Signed-off-by: Changyul Lee <lcy8047@xxxxxxxxx>
---
Found with an in-development static analysis tool.
Compile-tested only with x86_64_defconfig, INTEL_IOMMU=y, UACCE enabled,
and W=1.

drivers/misc/uacce/uacce.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/misc/uacce/uacce.c b/drivers/misc/uacce/uacce.c
index 45521d4a56d1..026f076fa0be 100644
--- a/drivers/misc/uacce/uacce.c
+++ b/drivers/misc/uacce/uacce.c
@@ -514,7 +514,7 @@ struct uacce_device *uacce_alloc(struct device *parent,
uacce->flags = flags;
uacce->ops = interface->ops;

- ret = xa_alloc(&uacce_xa, &uacce->dev_id, uacce, xa_limit_32b,
+ ret = xa_alloc(&uacce_xa, &uacce->dev_id, NULL, xa_limit_32b,
GFP_KERNEL);
if (ret < 0)
goto err_with_uacce;
@@ -550,6 +550,10 @@ int uacce_register(struct uacce_device *uacce)
if (!uacce)
return -ENODEV;

+ ret = xa_err(xa_store(&uacce_xa, uacce->dev_id, uacce, GFP_KERNEL));
+ if (ret)
+ return ret;
+
uacce->cdev = cdev_alloc();
if (!uacce->cdev)
return -ENOMEM;

base-commit: aebb7274476403040d582c61478df8f4a7bf9cd3
--
2.43.0