mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jean-Philippe Brucker <jpb@kernel.org>
To: Changyul Lee <lcy8047@gmail.com>
Cc: Zhangfei Gao <zhangfei.gao@linaro.org>,
	Zhou Wang <wangzhou1@hisilicon.com>,
	Arnd Bergmann <arnd@arndb.de>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Herbert Xu <herbert@gondor.apana.org.au>,
	linux-accelerators@lists.ozlabs.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] uacce: publish the device in uacce_register()
Date: Thu, 19 Nov 2026 15:48:58 +0000	[thread overview]
Message-ID: <20261119154858.GA733257@myrica> (raw)
In-Reply-To: <20261119015931.596086-1-lcy8047@gmail.com>

On Wed, Nov 18, 2026 at 08:59:31PM -0500, Changyul Lee wrote:
> 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@gmail.com>

Reviewed-by: Jean-Philippe Brucker <jpb@kernel.org>

> ---
> 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
> 

      reply	other threads:[~2026-11-19 15:48 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-19  1:59 Changyul Lee
2026-11-19 15:48 ` Jean-Philippe Brucker [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261119154858.GA733257@myrica \
    --to=jpb@kernel.org \
    --cc=arnd@arndb.de \
    --cc=gregkh@linuxfoundation.org \
    --cc=herbert@gondor.apana.org.au \
    --cc=lcy8047@gmail.com \
    --cc=linux-accelerators@lists.ozlabs.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=wangzhou1@hisilicon.com \
    --cc=zhangfei.gao@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®