From 615e1d89dc8c0fa7fc6ed2d57586949cec97fde2 Mon Sep 17 00:00:00 2001 From: dujunbao <14829755+du-junbao@user.noreply.gitee.com> Date: Tue, 22 Sep 2026 21:11:55 +0800 Subject: [PATCH] urma: uburma: return a negative errno when the ubcore device is gone uburma_open() reports a missing ubcore device with `ret = EIO`. EIO is positive, so the file operation returns 5 instead of an error code. The VFS requires ->open() to return a negative errno. do_dentry_open() runs the positive value through WARN_ON_ONCE() in cleanup_all and substitutes -EINVAL, so opening the character device while the ubcore device has already been detached (uburma_remove_dev() clears ubu_dev->ubc_dev) both emits a kernel warning and reports the wrong errno to userspace. Every other error return in this file and the surrounding URMA code uses a negative errno; do the same here. Fixes: 21bafff09f96 ("uburma: implement jetty resource control and command structures") --- drivers/ub/urma/uburma/uburma_dev_ops.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/ub/urma/uburma/uburma_dev_ops.c b/drivers/ub/urma/uburma/uburma_dev_ops.c index 51fb42ecddbc..8e0f637b67de 100644 --- a/drivers/ub/urma/uburma/uburma_dev_ops.c +++ b/drivers/ub/urma/uburma/uburma_dev_ops.c @@ -180,7 +180,7 @@ int uburma_open(struct inode *inode, struct file *filp) srcu_idx = srcu_read_lock(&ubu_dev->ubc_dev_srcu); ubc_dev = srcu_dereference(ubu_dev->ubc_dev, &ubu_dev->ubc_dev_srcu); if (!ubc_dev) { - ret = EIO; + ret = -EIO; uburma_log_err("can not find ubcore device.\n"); goto err; } -- Gitee