From: sashiko-bot@kernel.org
To: "Anandu Krishnan E" <anandu.e@oss.qualcomm.com>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH 1/2] misc: fastrpc: query the dsp capabilities during probe time
Date: Fri, 27 Nov 2026 10:23:17 +0000 [thread overview]
Message-ID: <sashiko-outbox-237113@kernel.org> (raw)
In-Reply-To: <20261127-master-v1-1-f998ec22497b@oss.qualcomm.com>
Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [High] misc: fastrpc: race between fastrpc_cap_query_work() and
fastrpc_rpmsg_remove()
- [Medium] misc: fastrpc: double misc_deregister() after
fastrpc_register_devices() error
--
commit 502b28e3abb8ed99c00c841e2045fedc442784d7
Author: Anandu Krishnan E <anandu.e@oss.qualcomm.com>
misc: fastrpc: query the dsp capabilities during probe time
This commit moves FastRPC device node registration out of
fastrpc_rpmsg_probe() into a per-channel workqueue that first queries
and caches the DSP capabilities before registering the device nodes.
> diff --git a/drivers/misc/fastrpc.c b/drivers/misc/fastrpc.c
> index 5375847d8c9a2..48ded6080ddd6 100644
> --- a/drivers/misc/fastrpc.c
> +++ b/drivers/misc/fastrpc.c
[ ... ]
> @@ -2585,6 +2617,195 @@ static int fastrpc_device_register(struct device *dev, struct fastrpc_channel_ct
> return err;
> }
>
> +static int fastrpc_register_devices(struct fastrpc_channel_ctx *cctx,
> + struct rpmsg_device *rpdev)
> +{
> + struct device *rdev = &rpdev->dev;
> + int err, i;
[ ... ]
> + case CDSP_DOMAIN_ID:
> + case GDSP_DOMAIN_ID:
> + cctx->unsigned_support = true;
> + /* Create both device nodes so that we can allow both Signed and Unsigned PD */
> + err = fastrpc_device_register(rdev, cctx, true, cctx->domain);
> + if (err)
> + goto err_deregister_fdev;
> +
> + err = fastrpc_device_register(rdev, cctx, false, cctx->domain);
> + if (err)
> + goto err_deregister_fdev;
> + break;
> + default:
> + err = -EINVAL;
> + goto err_deregister_fdev;
> + }
> +
> + return 0;
> +
> +err_deregister_fdev:
> + if (cctx->fdevice)
> + misc_deregister(&cctx->fdevice->miscdev);
> + if (cctx->secure_fdevice)
> + misc_deregister(&cctx->secure_fdevice->miscdev);
> +
> + return err;
> +}
[Severity: Medium]
Can this cause a double misc_deregister() in fastrpc_rpmsg_remove() if the
second fastrpc_device_register() call fails?
Previously, a registration failure aborted fastrpc_rpmsg_probe(), so
fastrpc_rpmsg_remove() never ran. Now probe returns 0 before
fastrpc_register_devices() runs, and fastrpc_cap_query_work() only logs the
error. Because err_deregister_fdev does not clear cctx->secure_fdevice or
cctx->fdevice after deregistering them, fastrpc_rpmsg_remove() will call
misc_deregister() on cctx->secure_fdevice->miscdev a second time after its
dynamic minor was already freed and reset to MISC_DYNAMIC_MINOR.
Also, at the register_devices label in fastrpc_cap_query_work(),
fastrpc_register_devices() runs using the initial rpdev snapshot without
re-checking whether fastrpc_rpmsg_remove() has already cleared cctx->rpdev.
> +
> +static void fastrpc_cap_query_work(struct work_struct *work)
> +{
> + struct fastrpc_channel_ctx *cctx =
> + container_of(work, struct fastrpc_channel_ctx, cap_query_work);
> + struct rpmsg_device *rpdev;
> + struct device *rdev;
> + u32 *dsp_attributes;
> + struct fastrpc_user *fl;
> + unsigned long flags;
> + int err;
[ ... ]
> + /*
> + * Linked into cctx->users so fastrpc_rpmsg_remove() can abort us
> + * via fastrpc_notify_users() instead of waiting out the timeout.
> + */
> + spin_lock_irqsave(&cctx->lock, flags);
> + if (!cctx->rpdev) {
> + spin_unlock_irqrestore(&cctx->lock, flags);
> + kfree(dsp_attributes);
> + fastrpc_session_free(cctx, fl->sctx);
> + fl->sctx = NULL;
> + fastrpc_user_put(fl);
> + return;
> + }
> + list_add_tail(&fl->user, &cctx->users);
> + spin_unlock_irqrestore(&cctx->lock, flags);
> +
> + err = fastrpc_get_info_from_dsp(fl, dsp_attributes, FASTRPC_MAX_DSP_ATTRIBUTES);
[Severity: High]
Can fastrpc_rpmsg_remove() clear cctx->rpdev and finish its
fastrpc_notify_users() pass after cctx->lock is dropped here, but before
fastrpc_get_info_from_dsp() sends the message?
kworker CPU0
fastrpc_cap_query_work()
spin_lock_irqsave(&cctx->lock)
list_add_tail(&fl->user, ...)
spin_unlock_irqrestore(&cctx->lock)
fastrpc_get_info_from_dsp()
fastrpc_internal_invoke()
if (!fl->cctx->rpdev)
fastrpc_rpmsg_remove()
spin_lock_irqsave(&cctx->lock)
cctx->rpdev = NULL
fastrpc_notify_users(fl)
/* fl->pending is still empty */
spin_unlock_irqrestore(&cctx->lock)
cancel_work_sync(&cctx->cap_query_work)
fastrpc_context_alloc()
...
fastrpc_invoke_send()
rpmsg_send(cctx->rpdev->ept, ...)
<-- NULL pointer dereference
If fastrpc_rpmsg_remove() runs after fastrpc_context_alloc() adds ctx to
fl->pending (while fastrpc_get_args() sleeps in dma_alloc_coherent()) and
before fastrpc_invoke_send() takes the worker reference with
fastrpc_context_get(ctx), fastrpc_notify_users() also schedules
ctx->put_work on a context with a refcount of 1, freeing ctx while
fastrpc_internal_invoke() is still using it.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261127-master-v1-0-f998ec22497b@oss.qualcomm.com?part=1
next prev parent reply other threads:[~2026-11-27 10:23 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-27 9:56 [PATCH 0/2] misc: fastrpc: probe-time DSP capability query and unsigned ADSP node Anandu Krishnan E
2026-11-27 9:56 ` [PATCH 1/2] misc: fastrpc: query the dsp capabilities during probe time Anandu Krishnan E
2026-11-27 10:23 ` sashiko-bot [this message]
2026-12-01 10:48 ` Murali Krishna
2026-11-27 9:56 ` [PATCH 2/2] misc: fastrpc: expose unsigned PD node for compute-capable ADSP Anandu Krishnan E
2026-11-27 10:06 ` Konrad Dybcio
2026-11-27 10:20 ` sashiko-bot
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=sashiko-outbox-237113@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=anandu.e@oss.qualcomm.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=sashiko-reviews@lists.linux.dev \
/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