From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.214.176 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796056324; b=5MOcwp0Y/8KYU5vSZYaoo0PJAEuDtDaSAA0a5K/GtOStBs0fgMohYTva6tKIfuHDa/8H 6ykY89Buq11JLK3vG+rhnxw8bVZs9I5Ex0/sxwB1DZOqaOCqK/rsHXrSTk9JldjqB3era iPSfWe3awkxVMcsYTVApzdCd0hb0XweN49ifjPu3Fcs4RkLjbnYuRKU0VSRS+rdHtU0k3 DhckW/tePRnNBf+wDhbPifi3exPeBLtOpNFdfb2AlXK3DJS/XYBghBm/JH/V0ZK70iKo6 /TCoGgvj38fPy8sTaAyoeBAHSI9YK51lTzx3KFEHTURn/03PzXXi+SJFx1xxhY0y1/w== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796056324; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; bh=cFKU1y1OWe+LNLr+YaRB0AV498oXIR99K/+LSMoaJbc=; b=C5oFoejdau/mVi2YhQ28WSgehD5vQIekn90UxePatix5sYN9EqH0VsJ5BJZ69t4HCdVr BdOO4gE2oRhr8EQf2FbgCDwQ5K3k2oCd2QzSnyzvk6KKVlB7E9DDb2Yp3ttSjb2ZEF7x2 yrtGi3CN66HQasakk9szdVYeO9Ezn8NK0BzHOgTxBrV+IcnRjJWA16jbK5SCHY3ZDUbOj 0miam5e0aJSs3xxPzZUFfM9jysDw2nuG94aAz1KTJDKV4+F7W8vgwJ2xpDffPRbKdQhRq gZMjIVFV8NitbwnBdCYc/Cq/G9LvqxjrECvwriqczK5QzUfwNjZAOrD0oY0rAq7svig== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=IBewGlDL; arc=none smtp.remote-ip=209.85.214.176 Received: from mail-pl1-f176.google.com (mail-pl1-f176.google.com [209.85.214.176]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 96602606A32C for ; Mon, 30 Nov 2026 16:32:03 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 96602606A32C Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=IBewGlDL Received: by mail-pl1-f176.google.com with SMTP id d9443c01a7336-2f020d0169eso52765155ad.0 for ; Mon, 30 Nov 2026 08:32:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1796056323; x=1796661123; darn=vger.kernel.org; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:from:to:cc:subject :date:message-id:reply-to:content-type; bh=cFKU1y1OWe+LNLr+YaRB0AV498oXIR99K/+LSMoaJbc=; b=IBewGlDL8n4jbHRB9YjiGh7QxcaINi+ZpUihQUCQe5WYhRB3Z6BnV6MkP63d0Y2m9y jCiw6jWMRlYpVnvhc+a8XKsik16iLRtKb3vaJFeA8D05giZ9J8crtFsRhObhsiI9iHHd 8DRJXmH9CuiLbnR/EmhQq3dhFxnbuu6EteToVzquuZkyxFyNtgMOC2MiRfyQGtJzm9sg XCkKcgWhJv+kFpp5+QxxIoyUC82EL/hJy3hZV5cAXuvk8H38si4yvRGc3iBTZrElKorY I1+Az3cJ7k+EqdFVsWnw97LsikDQaxWIbs+Rokx3nda3nWdu1cWkN5yGp3Cq1l0/qdFD gGdg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796056323; x=1796661123; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=cFKU1y1OWe+LNLr+YaRB0AV498oXIR99K/+LSMoaJbc=; b=XiiQoFc5EdakIQnphkjqW7GnED+eDz2Tll3Ulr8+FZPxm4jYinT1CcsQrx8TU11xi1 xOHCA3rWto2Io2JNCFBwAJLXBOPWEGBsmHlCVkL/54ymkl1sLegn3F94EbeN9WPPzHd3 u+g84StWn1D0UTPFCgwhnZ0iq9/FX2PfXR993yLIL7Z4ihoGRg/iPNQLPrjM6mbOsWBS bM01rlqX7ehP8EpfNef5Rg6J9ASmAEJVDe8CmaKUXZjy1//Qi7+YY/YTcUe087vwm9Qd pONToNAXVFooD1feoU6Yw9HmbzOZ/eyZQGQFV+CHhctcLTgUWIQW34fXuNixF41kV7lH q6tQ== X-Forwarded-Encrypted: i=1; AL+hErF9fiLWABUIbeFVXrScuIG5iyIRLj9tG6sa9fvngOFIbSQzq8N1fgep3McJbHrnjyI72RvU/ksAA4DEvCM=@vger.kernel.org X-Gm-Message-State: APuU4Z8wGIKIzdlPjLp63JxsTPpgr0JBQzCW7qXrao/ITaSg62Ets4yv 9SVdEudeU0KwIClSjUgkOOA2Lzag0S+MMFf4g1RwkekVg/Pcd6AGUMicehu4tpMr7a8= X-Gm-Gg: AZFdTZdcD/0HNg/c6gGL7sIYBN9Yhp91SM5FcBB0+uz/veScJ2cGlPvRcIxsGO1Ihoi GtPdKufd7W45rZ9TbD1de0QjZHsd/MA+rgI18ug/6VEIq+ReVEoZxw/H5f3WTb4i9ONmCOPeE3D r/LqFB2gCWKPsnNKNg/NuWnBmqCV0upHdtpM+7RWjHlF8+rUip8ViGbF+WdgpXrEqVqoS3fnJJg HY15Xo1/3iT4TnlCL5CuK335W9Wkmfd1nRwQWpux46BnIurvNOaPqbH297L3GiwbD9JKc1tkLkm OkaiRUw9LS6yLMZh4EM3IQ7WvgsCXLxRhrfploMfbUTKXRcLFLtcN6O5gjXsS4Uo82HOy0QrACR qfWVtpJl3PfnaSTF3y9okb9A4ojuHKBExlhgpSFPOrfLlLK5Ncg/WePJn05Koe9SEnrRQJw0Qty CYvy7moJIVEU/r3o9ZvQcD1CKdcyptHTIuZ3amc5WFvsWjL7QydCX7AYZgyRXsxtrnZXqNMPUb8 5Si3NaXHtqNFVmF2Ry1dKkHpIxFu3B6yczz5WiHu9jwBFHGxAJTRwHr5MxLjLH0bOhhPC37srik r3A/IwDo16sdxMTD87+2Bizjb8nbzGEz X-Received: by 2002:a17:902:e5c1:b0:2f0:44b2:645c with SMTP id d9443c01a7336-2f044b26739mr350467835ad.2.1796056322543; Mon, 30 Nov 2026 08:32:02 -0800 (PST) Received: from p14s ([2604:3d09:148c:c800:c67b:8f68:1819:dc4b]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2f03ee84425sm171171885ad.6.2026.11.30.08.32.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Nov 2026 08:32:02 -0800 (PST) Date: Mon, 30 Nov 2026 10:32:00 -0600 From: Mathieu Poirier To: shyckless@gmail.com Cc: andersson@kernel.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 Message-ID: References: <20261118-omap-rproc-v1-1-c2824060fd10@gmail.com> X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline 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 > > 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 > Signed-off-by: Kaixuan Li > Signed-off-by: Suyuan Wang > --- > 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(-) > Applied. Thanks, Mathieu > 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; > > > > >