From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-yw1-f172.google.com (mail-yw1-f172.google.com [209.85.128.172]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C2EF333F59B for ; Fri, 17 Jul 2026 19:57:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=pass smtp.client-ip=209.85.128.172 ARC-Seal:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784318236; cv=pass; b=TK+lXwuNv0MsJ2up9I2F4Y38Ep8zJWbSE4abpGyS828dEpg1AW/H5nTitUaNK58d5hjKkHUAXOUQ6sxqaYetcGb9pbGqzJ0jWV3yNHGbGmfHjJYksDjGQTN9z6jqQ3kSpK+UyHzGlDOphMQy0cFwUY7uUcPnSr96mnhsagth/X4= ARC-Message-Signature:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784318236; c=relaxed/simple; bh=uuOeXfineAaSKEkzm9ZAfY9YAcij/EcCbR2zNaGpEpY=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=ktFDmYhqYjlkoqRLE/KdxDR3PWvkGjIEriW2wmYewWYbOHCub3V2o38Q4lMBbp84WC6X9UxqK2C/XdQIjwpSCPVxqtjjwX5R8vx+RKgJu38nU4Bi98ZYRcbdIzk2wufdI3R+papCHk2iIdpe3ExylHK4/723nkRaCNsPnsY9iKo= ARC-Authentication-Results:i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=eNyTUgU7; arc=pass smtp.client-ip=209.85.128.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="eNyTUgU7" Received: by mail-yw1-f172.google.com with SMTP id 00721157ae682-81eac8bf7dcso4065347b3.0 for ; Fri, 17 Jul 2026 12:57:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1784318234; cv=none; d=google.com; s=arc-20260327; b=eSwNdZIiCyOrk08e6VxWMU9zhrx6EdxTS23Y3cMNPquu8ABAiYNTishgmGgVAZve61 3yNi9f7k2HIOqqPnL/PurgDAbWuZf5+ZsPSLUR9aFsee+YEj6IxLW7gCcOx32c8yMnu5 vJnREfrFjIVQGfGeJ+/j9318Mkgn0qFsPiIAnL0SYLRda4L5Y+q/QC+ahQ2qvaVjMjhl +Q9oWuovvmkRuOE6cDmb2542h0QMLUim+HPZPo2FTY/no+2+ojCp34V1S4DzGBjClgFn aZXoLrOtlm9d7gJc2M2awQYyY4n3zU2c76uIK7JQm/SMJpmiQOSjPzWAL95GH42LAPMC GA3w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20260327; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=+4r4qpI7ZYUqwhCzIi/TmFSyDrOhyXUmyBS8Pxgob6U=; fh=cGfwsGa6D3SEEzgp0fVVT97fZXn5ljaFRmoQskjJbqw=; b=dXotMj+J2lB/C5aeTropSSo0ngJbo+10bbmA3x9u/7sCP4WZBwJAMoh4+bJe1MMZaM TLp6NUzLsZZ3LYr0EUN61uGwGwmWIieXPk2pN1LFvwgIR56IOlrUeUVgsS10AO7nWjDQ 9srgJY0x9SaDz1hVBICNKf2K9IVQwB7iyP/o/NkMiiVZDDN0vzwyvAXxGS8wAgzkRehn 8c/H6SkZcyRMh7zYFdWvkb7rvJs0A0m69H+VLTvTQcQGtsoSZS87Zg4q02JaLpfoMWfL BAXvqjaNGiMirB2Dx7UsqbhA8XLZSfVhKhn/kyxCFM8O0+4SqrQV4aRflQBNfjDqkuen oosw==; darn=vger.kernel.org ARC-Authentication-Results: i=1; mx.google.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1784318234; x=1784923034; darn=vger.kernel.org; h=content-transfer-encoding:content-type:cc:to:subject:message-id :date:from:in-reply-to:references:mime-version:from:to:cc:subject :date:message-id:reply-to:content-type; bh=+4r4qpI7ZYUqwhCzIi/TmFSyDrOhyXUmyBS8Pxgob6U=; b=eNyTUgU7+U1nHHE1U6fzUA7qpVfYDsJJijHQjAeZO0w1wW7uOJ41TEqaFbAzE+BS+d d09C3s/Z1dhWrBSqEyF03kqvbjLIM/edSCUE8o7HIPrVfHsJvTKWnC0huxT1dLsXvjGn LJDMiEJleiYcAZp2TTXA+q+tgxucslh4QgJdjVLJtCuTeWKyzrDDMc2HjSFsOLGMks90 9IM6kIdiSI+vno4ut+CVj8hnqDRSLWEBll2k3SovxxUB0KsyTsP9x534BwlcxY8YCpUt +yXwacWfP/aKsYHUvFPncVjv3mlzzSLzO0FuCyiEdBnHVOqmtB/pZk4GKbzV2qPP2cmI xo1w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784318234; x=1784923034; h=content-transfer-encoding:content-type:cc:to:subject:message-id :date:from:in-reply-to:references:mime-version:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=+4r4qpI7ZYUqwhCzIi/TmFSyDrOhyXUmyBS8Pxgob6U=; b=NSLiTtAMZpvI03Ef3mLm4d4KEUuVN9O1wBVtVKNF0Y8FMy+F1jG0A9YZBcdKIzSmH0 ih+Jv9uksIJWwmU15gBZmBVSZ/cODkOco/f97QM2Gzqx82ubA5WY8vJklEuf/Gc6NX6e ARRLAh1Xhq9DIUGUkhbKnfBQ3HCjJTNSz0l4RgBdqJFBgyi973dJSLyDG6maLCjnjy3I XxE27fsAgJnWAJfJbzH2KG5NEbXXz9hlIEieqKM4uHLPhRX1TDyT+AmgQk4E/11Nw6gz BjA1PqEE2WeKdh3axMLBRF8lB8Pdza4+XnrTv1ojzSpSH0yzPoO1O3ibXIC+l+AxFevG 4nEw== X-Forwarded-Encrypted: i=1; AHgh+Rp0pwv5tswetAo5UYfQZxHsfhjJRi8wK95g+YWZ2+BD9sIzOBA+eLgS5v3Pr5TwUXkAG4ZKu60aPsWVxMs=@vger.kernel.org X-Gm-Message-State: AOJu0YzuIsiB6D2a8S4m/GnxejJBkfUn3Ue9sc5oggMUNU0ZfjF9iDK2 WAldzZBE2NR6knBlvf+0LXQanTRLlRk1ogOYrjNtUUDnNmWtY8SVdr0J0xuB8mSXVl5aSMu/S4D hz6FEPT6pMRII3OG+L/XxCFXIGKZokMQ= X-Gm-Gg: AfdE7cmFfzOBlVLbpmDG/j/urES70HJPF80UfSj1AtSesC48vxk99jQ9jJ6kWhkU32b gWOIM0GaQ7WOYtwNGKmja6OiPKwJWXFxbai2oeQr6BAJqC/ZfxWt2vo505foxSv4+z5TkU2UU1L A4h02uswy1I/cJo3/cNtsWP+mgEopBTzMkWsowDvoggto3wbt1Fc9QjMGXPrikpnACeQ6vO/ip4 FR+ixgrcD726AlLaOW8ZSn+B7xuYMvFRRHhxw/nxZk0DBwvjDmrLxc5PpMl1y9KL8ci4vwswWo= X-Received: by 2002:a05:690c:60c3:b0:80d:8bad:2ceb with SMTP id 00721157ae682-81ef217a008mr13797247b3.0.1784318233761; Fri, 17 Jul 2026 12:57:13 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20260710194638.1502-1-saileshnandanavanam@gmail.com> In-Reply-To: From: Sailesh Nandanavanam Date: Sat, 18 Jul 2026 01:27:09 +0530 X-Gm-Features: AUfX_mybpP0ipFenvhQ7910IFz9oFbDJFCxR2LMB6JHjtp_vKzBdXraXDoqWrzE Message-ID: Subject: Re: [PATCH] remoteproc: qcom_q6v5_mss: Fix off-by-one error in regulator error cleanup To: Konrad Dybcio Cc: andersson@kernel.org, mathieu.poirier@linaro.org, quic_akdwived@quicinc.com, linux-arm-msm@vger.kernel.org, linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On 7/17/26 3:01 PM, Konrad Dybcio wrote: > The first two labels only unwind a single regulator Thanks for taking a look. Could you clarify whether this is a correctness concern (e.g. the fallthrough from err_enable/err_set_load into err_set_voltage not doing what you'd expect), or more a structural/style preference (e.g. avoiding three chained labels in favor of a different approach)? Happy to send a v2 once I understand what you'd like changed. Thanks, Sailesh On Fri, Jul 17, 2026 at 3:01=E2=80=AFPM Konrad Dybcio wrote: > > On 7/10/26 9:46 PM, Sailesh Nandanavanam wrote: > > In q6v5_regulator_enable(), when any operation fails for regulator at > > index 'i', the error cleanup path unconditionally calls > > regulator_disable() starting from index 'i'. However, regulator 'i' > > was never successfully enabled at this point, resulting in an > > unbalanced disable. > > > > There are three distinct failure points: > > - regulator_set_voltage() failure: voltage was never set, load was > > never set, regulator was never enabled. > > - regulator_set_load() failure: voltage was set, but regulator was > > never enabled. > > - regulator_enable() failure: voltage and load were set, but > > regulator was never enabled. > > > > Fix this by introducing three separate error labels to handle each > > failure point correctly. For the failing regulator at index 'i', > > only reset the resources that were actually configured, without > > calling regulator_disable(). Then roll back all previously enabled > > regulators using 'i--' in the for loop initializer to skip the > > never-enabled regulator. > > > > Fixes: 19f902b53b47 ("remoteproc: qcom: Initialize and enable proxy and= active regulators.") > > Cc: stable@vger.kernel.org > > Signed-off-by: Sailesh Nandanavanam > > --- > > [...] > > > -err: > > - for (; i >=3D 0; i--) { > > +err_enable: > > + if (regs[i].uA > 0) > > + regulator_set_load(regs[i].reg, 0); > > +err_set_load: > > + if (regs[i].uV > 0) > > + regulator_set_voltage(regs[i].reg, 0, INT_MAX); > > The first two labels only unwind a single regulator > > Konrad