From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.214.175 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796056324; b=XEreRV1V/F0NkA2+UlsG7CnM4OYEff7n22A2C+iiKY7gGxOwsCpDIST6SESrvLPzYk0G YHlH7pRGZ/rEUzFrfF8DECOxvt9Dwp0gvR9tltLig+iWMKuvW2r69XprI/8C1r8m3uYBC Qto7WSrj5x5rV7jra6zog2A+WD0Y/V286ukpY3mD4K2B/JHcyW3ile+iL3jRei3qkeJ/H kUiiwx61yr7aEglll+z7qK/mlVYiwu6ViC3anMpsPcmU7EyAOVPUl9OX15cHsjt3JsRub i8JvUGw8oqCFB3CgEz7Is1epHV+7myGfeyBUZ2ELM0l28bP4EePlGEnMdIzYYj7HkXQ== 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=vMKTSTyQ/nSgmH9npryXSergJkLWgzgaWisthopwWKXuLhf5Oa8aWLxrpbQv+7DIHEBu f0IlWWDH8lv6YgQnEKhk/7jXKCmnzAlOUXgWhz1eTVxrd5c9YWEk3D5howHetDOOJvOoZ Bj/pMiZmXV6IZZA0SFzaCeVXMflSUusdott0DW/bzjvTYOQw6/dEjBT9XTZ90AyKCPjGU hYXhVi5/6TZnPeCi2Khg6vGb0rglCiVnzXlMkOeLQPQJRCAAV4Jhmnpq1ZDdW51nDZtRY CIzyeWu8fOv78F0jYAE9rt/7BBEsKWXVUqOsK64184LLXeHe8xC+3vArGb2NL0BzCHg== 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.175 Received: from mail-pl1-f175.google.com (mail-pl1-f175.google.com [209.85.214.175]) (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 9EFF9606A330 for ; Mon, 30 Nov 2026 16:32:03 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 9EFF9606A330 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-f175.google.com with SMTP id d9443c01a7336-2f0458cc9easo83317395ad.3 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=JjepV3cBqEpzMptxxyN0IaYTRxMVY197Kaw6LCPuRAasc35Ywp215yiBicCYpLMvNV 8RXBoFKnRI+sGL+aRZrKW3qpMXjaFZqiInboOOUrDZzlsw1pnVy2qne4u4gGbLg5STTX VFl5nPxyX6wclkP1xZWr8hpK0Put8luEiDsoGNn7eZN8oIqQRD5Ok6ObfoC8XBcQqrTS 6jq8X+cTSHT0bB6HHs8f+NOg7ZTqSAsI79n66YnwPJnEUYM2m6DTs9jEGSAr7EddLvvW U5IDs/wui754HYoAiSnMiVnsGYFD4tTuVDVWK1fvXrmfX7kRCeSvq+W/oE8ObF4ohUtW EsDg== X-Forwarded-Encrypted: i=1; AL+hErGGlXwctpTCC1jWvBnqff51cm9nMkVA4hfHcVUFfkeiB/ZlbujkqKzhzrenYu0N7zyFsRGacFJeTbjo@vger.kernel.org X-Gm-Message-State: APuU4Z+XsaGsaDc13BPdi8NppM8Vf2HsIXOk1fJVvsL9viQUV9Jylzvm 0aZNDljhE0Dw1GvJmACVi+yokhuTbvEEUL4tARUnEVBzgHYh/KyhNDbX/DSy3kg7c6w= X-Gm-Gg: AZFdTZfOiFsPq4+5RgzqqQ2NyBN7zI80lUYAGAu1TQ8306Mlwv067Rzxi0H9tChZIn6 TZqkdL2PrEZH0r6Z7PbAIc3kOzSO3AKZFHSeEdsVNjl12u/if3rjeUUMbGeX+e0rLozH0ex5sXN /3G3YP5Ud6qpwb4o92E1AthOB7ISxo/E56xCZZV0+v3A/bsQHRQY/u1rKFUrx0snAC8wd35pIC2 mmoO90HbtW6CrO9lOPLnD29rKSgIepKr+FHf82Gb8FZhHRmSMJgcfJ4iSY1iU2p+STAgxUCPIyC KNINatJhktuVlLYUxjYBvhg5JUbUnbRnC7IaZBy51BT/+8A0q359lKBvWKH4snzPGAzKOsa5yzh 8MDZj7JjoksI5dZtooUNbAUptmalHEePdpCRIUYffvKyPKyNIBBiQfQLOynSQgKTh3nW4uPhgcn 1EjVPtrQZmnf+fQud0KIQya22uGo3NXvQ/N77VBhbnfwr+oK9dvD+feMcFENAWXdZGxedDsirxC AWlMX7WsqvKUWKuaXBVvS8I+mVokAaIAuX0RA4mX5kSYf4mj9JF5Rt+HH2/Sqb779jfgFzPp2+i OshchQFGpAD167DNw13OCLc0iwUJNIgd 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-omap@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; > > > > >