From: Stephan Gerhold <stephan.gerhold@linaro.org>
To: Jingyi Wang <jingyi.wang@oss.qualcomm.com>
Cc: Bjorn Andersson <andersson@kernel.org>,
Mathieu Poirier <mathieu.poirier@linaro.org>,
aiqun.yu@oss.qualcomm.com, tingwei.zhang@oss.qualcomm.com,
trilok.soni@oss.qualcomm.com, yijie.yang@oss.qualcomm.com,
linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 2/3] remoteproc: core: Check subdev start status in rproc_stop()
Date: Fri, 22 May 2026 14:14:46 +0200 [thread overview]
Message-ID: <ahBItk6iPQTGaZWT@linaro.org> (raw)
In-Reply-To: <20260519-rproc-attach-issue-v2-2-caa1eaf75081@oss.qualcomm.com>
On Tue, May 19, 2026 at 12:20:03AM -0700, Jingyi Wang wrote:
> For rproc that doing attach, rproc_start_subdevices() is called only when
> attach successfully. If rproc_report_crash() is called in the attach
> function, rproc_boot_recovery()->rproc_stop()->rproc_stop_subdevices()->
> glink_subdev_stop() could be called and cause NULL pointer dereference:
>
> Unable to handle kernel NULL pointer dereference at virtual address 0000000000000300
> Mem abort info:
> ...
> pc : qcom_glink_smem_unregister+0x14/0x48 [qcom_glink_smem]
> lr : glink_subdev_stop+0x1c/0x30 [qcom_common]
> ...
> Call trace:
> qcom_glink_smem_unregister+0x14/0x48 [qcom_glink_smem] (P)
> glink_subdev_stop+0x1c/0x30 [qcom_common]
> rproc_stop+0x58/0x17c
> rproc_trigger_recovery+0xb0/0x150
> rproc_crash_handler_work+0xa4/0xc4
> process_scheduled_works+0x18c/0x2d8
> worker_thread+0x144/0x280
> kthread+0x124/0x138
> ret_from_fork+0x10/0x20
> Code: a9be7bfd 910003fd a90153f3 aa0003f3 (b9430000)
> ---[ end trace 0000000000000000 ]---
>
> Introduce "subdevs_started" flag to indicate rproc_start_subdevices() has
> been called successfully. Ensure subdevices are only stopped if they have
> been started.
>
> Signed-off-by: Jingyi Wang <jingyi.wang@oss.qualcomm.com>
> ---
> drivers/remoteproc/remoteproc_core.c | 4 +++-
> include/linux/remoteproc.h | 2 ++
> 2 files changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c
> index f02db1113fae..6e23cb11e515 100644
> --- a/drivers/remoteproc/remoteproc_core.c
> +++ b/drivers/remoteproc/remoteproc_core.c
> @@ -1308,6 +1308,7 @@ static int rproc_start(struct rproc *rproc, const struct firmware *fw)
> goto stop_rproc;
> }
>
> + rproc->subdevs_started = true;
> rproc->state = RPROC_RUNNING;
>
> dev_info(dev, "remote processor %s is now up\n", rproc->name);
> @@ -1712,7 +1713,8 @@ static int rproc_stop(struct rproc *rproc, bool crashed)
> return -EINVAL;
>
> /* Stop any subdevices for the remote processor */
> - rproc_stop_subdevices(rproc, crashed);
> + if (rproc->subdevs_started)
> + rproc_stop_subdevices(rproc, crashed);
Thanks, this approach looks better. But where do we clear this flag?
Shouldn't we do that here?
In addition, I think we also need to set subdevs_started = true if
attach succeeds. And clear it when detaching a remoteproc. I think you
just need to update all the callers of rproc_stop_subdevices() and
rproc_start_subdevices(). Or, which is probably simpler, just make the
check directly inside these two functions to cover all users.
Thanks,
Stephan
next prev parent reply other threads:[~2026-05-22 12:14 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-19 7:20 [PATCH v2 0/3] remoteproc: improve robustness for rproc_attach fail cases Jingyi Wang
2026-05-19 7:20 ` [PATCH v2 1/3] remoteproc: core: Attach rproc asynchronously in rproc_add() path via schedule_work() Jingyi Wang
2026-05-19 7:20 ` [PATCH v2 2/3] remoteproc: core: Check subdev start status in rproc_stop() Jingyi Wang
2026-05-22 12:14 ` Stephan Gerhold [this message]
2026-05-28 3:31 ` Jingyi Wang
2026-05-19 7:20 ` [PATCH v2 3/3] remoteproc: core: cancel crash_handler work in rproc_add() error path Jingyi Wang
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=ahBItk6iPQTGaZWT@linaro.org \
--to=stephan.gerhold@linaro.org \
--cc=aiqun.yu@oss.qualcomm.com \
--cc=andersson@kernel.org \
--cc=jingyi.wang@oss.qualcomm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-remoteproc@vger.kernel.org \
--cc=mathieu.poirier@linaro.org \
--cc=tingwei.zhang@oss.qualcomm.com \
--cc=trilok.soni@oss.qualcomm.com \
--cc=yijie.yang@oss.qualcomm.com \
/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
Powered by JetHome