All of lore.kernel.org
 help / color / mirror / Atom feed
From: Francesco Valla <francesco@valla.it>
To: shyckless@gmail.com
Cc: andersson@kernel.org, mathieu.poirier@linaro.org,
	 linux-remoteproc@vger.kernel.org, linux-omap@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] remoteproc: omap: Fix cleanup after timer start failure
Date: Sat, 28 Nov 2026 00:08:33 +0100	[thread overview]
Message-ID: <awoLFmA_kZe2XXwt@bywater> (raw)
In-Reply-To: <20261118-omap-rproc-v1-1-c2824060fd10@gmail.com>

On Wed, Nov 18, 2026 at 03:38:25PM +0000, Suyuan Wang via B4 Relay wrote:
> From: Suyuan Wang <stevewong@hust.edu.cn>
> 
> When omap_rproc_start_timer() fails in omap_rproc_enable_timers(), the
> error handling has three problems.
> 
> First, the stop loop also stops the timer that failed to start:
> 
> 	while (i >= 0) {
> 		omap_rproc_stop_timer(&timers[i]);
> 		i--;
> 	}
> 
> omap_dm_timer_start() drops its runtime PM reference when
> pm_runtime_resume_and_get() fails, so stopping that timer calls
> pm_runtime_put_sync() once more than it should.
> 
> Second, the loop leaves i at -1 and then jumps to put_node, which falls
> through to free_timers:
> 
> 	while (i--) {
> 		...
> 		omap_rproc_release_timer(&timers[i]);
> 
> With i == -1 the condition is true and the first iteration uses
> timers[-2]. The loop then keeps going through negative indexes.
> 
> Third, when configure is true, put_node puts np again. The parse loop
> already put every node it got, and np still points at the last one, so
> that reference is dropped twice.
> 
> Only stop the timers that were started. On resume (configure == false)
> return the error and keep the timers: they still belong to the driver
> and are released later by omap_rproc_disable_timers(rproc, true). On the
> first start (configure == true) release all the timers that were set up
> and skip put_node, since no node reference is held at this point.
> 
> Found with a static analysis tool and checked by hand.
> 
> Fixes: e28edc571925 ("remoteproc/omap: Request a timer(s) for remoteproc usage")
> Cc: stable@vger.kernel.org
> Co-developed-by: Kaixuan Li <kaixuan.li@ntu.edu.sg>
> Signed-off-by: Kaixuan Li <kaixuan.li@ntu.edu.sg>
> Signed-off-by: Suyuan Wang <stevewong@hust.edu.cn>
> ---
> Compile tested on arm with clang (W=1, no new warnings). I don't have
> the hardware, so the failure path hasn't been run.
> ---
>  drivers/remoteproc/omap_remoteproc.c | 11 +++++++----
>  1 file changed, 7 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/remoteproc/omap_remoteproc.c b/drivers/remoteproc/omap_remoteproc.c
> index f52a531877ae..d50f2e993c4e 100644
> --- a/drivers/remoteproc/omap_remoteproc.c
> +++ b/drivers/remoteproc/omap_remoteproc.c
> @@ -418,11 +418,14 @@ static int omap_rproc_enable_timers(struct rproc *rproc, bool configure)
>  		}
>  	}
>  	if (ret) {
> -		while (i >= 0) {
> +		while (i--)
>  			omap_rproc_stop_timer(&timers[i]);
> -			i--;
> -		}
> -		goto put_node;
> +
> +		if (!configure)
> +			return ret;
> +
> +		i = num_timers;
> +		goto free_timers;
>  	}
>  	return 0;
>

Reviewed-by: Francesco Valla <francesco@valla.it>

Regards,
Francesco


  reply	other threads:[~2026-11-27 23:08 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-18 15:38 [PATCH] remoteproc: omap: Fix cleanup after timer start failure Suyuan Wang
2026-11-18 15:38 ` Suyuan Wang via B4 Relay
2026-11-27 23:08 ` Francesco Valla [this message]
2026-11-30 16:32 ` Mathieu Poirier

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=awoLFmA_kZe2XXwt@bywater \
    --to=francesco@valla.it \
    --cc=andersson@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-omap@vger.kernel.org \
    --cc=linux-remoteproc@vger.kernel.org \
    --cc=mathieu.poirier@linaro.org \
    --cc=shyckless@gmail.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.