Linux Remote Processor Subsystem development
 help / color / mirror / Atom feed
From: Bjorn Andersson <andersson@kernel.org>
To: Pradnya Dahiwale <pradnya.dahiwale@oss.qualcomm.com>
Cc: Bjorn Andersson <bjorn.andersson@oss.qualcomm.com>,
	 Mathieu Poirier <mathieu.poirier@linaro.org>,
	Shengjiu Wang <shengjiu.wang@nxp.com>,
	 Fernando Guzman Lugo <fernando.lugo@ti.com>,
	Ohad Ben-Cohen <ohad@wizery.com>,
	linux-arm-msm@vger.kernel.org,  linux-remoteproc@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/3] remoteproc: Prevent crash handling to race with rproc_del()
Date: Mon, 27 Jul 2026 20:18:09 -0500	[thread overview]
Message-ID: <amgCxllAAnFCp2TD@baldur> (raw)
In-Reply-To: <amel8GzMOTlIM8jL@hu-pdahiwal-hyd.qualcomm.com>

On Tue, Jul 28, 2026 at 12:09:44AM +0530, Pradnya Dahiwale wrote:
> On Thu, Jul 23, 2026 at 03:52:28AM +0000, Bjorn Andersson wrote:
> > @@ -2598,16 +2609,21 @@ EXPORT_SYMBOL(rproc_put);
> >   */
> >  int rproc_del(struct rproc *rproc)
> >  {
> > +	spin_lock_irqsave(&rproc->crash_handler_lock, flags);
> > +	WRITE_ONCE(rproc->deleting, true);
> > +	spin_unlock_irqrestore(&rproc->crash_handler_lock, flags);
> > +
> > +	if (cancel_work_sync(&rproc->crash_handler))
> > +		pm_relax(rproc->dev.parent);
> > +
> >  	/* TODO: make sure this works with rproc->power > 1 */
> >  	rproc_shutdown(rproc);
> 
> rproc_del() cancels the crash-handler work here - should there also be a
> matching cancel_work_sync(&rproc->attach_work)? If attach_work were still
> pending when rproc_del() finishes and rproc_free() drops the last reference,
> could it later run rproc_boot() on a freed rproc?
> 
> rproc_del()                        attach_work (still queued)
>      |
> WRITE_ONCE(deleting, true)
>      |
> cancel_work_sync(crash_handler)
>      |
> rproc_shutdown()
>      |
> device_del()
>      |
> rproc_del() returns
>      |
> (driver's remove path then calls)
>      |
> rproc_free()
>                                    attach_work runs
>                                    container_of(work, rproc, attach_work)
>                                    rproc_boot(rproc)  <- freed rproc?
> 
> The deleting check inside rproc_boot() dereferences rproc itself, so it can't
> guard a freed one. The request_firmware_nowait() / rproc_auto_boot_callback()
> path looks similar.
> 

I agree with your analysis! Let's continue this journey and make sure
these gaps are addressed.

> Reviewed-by: Pradnya Dahiwale <pradnya.dahiwale@oss.qualcomm.com>

Thank you,
Bjorn

  reply	other threads:[~2026-07-28  1:18 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-23  3:52 [PATCH 0/3] remoteproc: Improve removal of remoteproc drivers Bjorn Andersson
2026-07-23  3:52 ` [PATCH 1/3] remoteproc: Allow shutdown of crashed processors Bjorn Andersson
2026-07-23  9:34   ` Konrad Dybcio
2026-07-23 10:00   ` Mukesh Ojha
2026-07-23  3:52 ` [PATCH 2/3] remoteproc: Prevent crash handling to race with rproc_del() Bjorn Andersson
2026-07-23 10:09   ` Konrad Dybcio
2026-07-23 15:16     ` Mukesh Ojha
2026-07-23 22:29     ` Bjorn Andersson
2026-07-23 14:47   ` Mukesh Ojha
2026-07-23 15:19     ` Mukesh Ojha
2026-07-27 18:39   ` Pradnya Dahiwale
2026-07-28  1:18     ` Bjorn Andersson [this message]
2026-07-23  3:52 ` [PATCH 3/3] remoteproc: Force shutdown during device removal Bjorn Andersson
2026-07-23  9:59   ` Konrad Dybcio
2026-07-23 10:54   ` Konrad Dybcio
2026-07-23 16:12     ` Mukesh Ojha
2026-07-23 22:16     ` Bjorn Andersson
2026-07-27 18:47   ` Pradnya Dahiwale
2026-07-28  2:04 ` [PATCH 0/3] remoteproc: Improve removal of remoteproc drivers Bjorn Andersson

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=amgCxllAAnFCp2TD@baldur \
    --to=andersson@kernel.org \
    --cc=bjorn.andersson@oss.qualcomm.com \
    --cc=fernando.lugo@ti.com \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-remoteproc@vger.kernel.org \
    --cc=mathieu.poirier@linaro.org \
    --cc=ohad@wizery.com \
    --cc=pradnya.dahiwale@oss.qualcomm.com \
    --cc=shengjiu.wang@nxp.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