From: Bjorn Helgaas <helgaas@kernel.org>
To: Geert Uytterhoeven <geert+renesas@glider.be>
Cc: "Bartosz Golaszewski" <brgl@bgdev.pl>,
"Bjorn Helgaas" <bhelgaas@google.com>,
"Krzysztof Wilczyński" <kwilczynski@kernel.org>,
"Manivannan Sadhasivam" <mani@kernel.org>,
"Marek Vasut" <marek.vasut+renesas@mailbox.org>,
linux-pci@vger.kernel.org, linux-renesas-soc@vger.kernel.org,
linux-kernel@vger.kernel.org,
"Manivannan Sadhasivam" <manivannan.sadhasivam@linaro.org>,
"Bartosz Golaszewski" <bartosz.golaszewski@linaro.org>
Subject: Re: [PATCH v2] PCI/pwrctrl: Fix double cleanup on devm_add_action_or_reset() failure
Date: Wed, 13 Aug 2025 14:35:10 -0500 [thread overview]
Message-ID: <20250813193510.GA287916@bhelgaas> (raw)
In-Reply-To: <7b1386e6162e70e6d631c87f6323d2ab971bc1c5.1755100324.git.geert+renesas@glider.be>
On Wed, Aug 13, 2025 at 05:56:25PM +0200, Geert Uytterhoeven wrote:
> When devm_add_action_or_reset() fails, it calls the passed cleanup
> function. Hence the caller must not repeat that cleanup.
>
> Replace the "goto err_regulator_free" by the actual freeing, as there
> will never be a need again for a second user of this label.
>
> Fixes: 75996c92f4de309f ("PCI/pwrctrl: Add pwrctrl driver for PCI slots")
> Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
> Reviewed-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
> Reviewed-by: Marek Vasut <marek.vasut+renesas@mailbox.org>
> Tested-by: Marek Vasut <marek.vasut+renesas@mailbox.org> # V4H Sparrow Hawk
> Acked-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Applied to pci/pwrctrl for v6.18, thanks!
> ---
> Compile-tested only.
>
> v2:
> - Add Reviewed-by, Tested-by, Acked-by.
> ---
> drivers/pci/pwrctrl/slot.c | 12 +++---------
> 1 file changed, 3 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/pci/pwrctrl/slot.c b/drivers/pci/pwrctrl/slot.c
> index 6e138310b45b9f7e..3320494b62d890ff 100644
> --- a/drivers/pci/pwrctrl/slot.c
> +++ b/drivers/pci/pwrctrl/slot.c
> @@ -49,13 +49,14 @@ static int pci_pwrctrl_slot_probe(struct platform_device *pdev)
> ret = regulator_bulk_enable(slot->num_supplies, slot->supplies);
> if (ret < 0) {
> dev_err_probe(dev, ret, "Failed to enable slot regulators\n");
> - goto err_regulator_free;
> + regulator_bulk_free(slot->num_supplies, slot->supplies);
> + return ret;
> }
>
> ret = devm_add_action_or_reset(dev, devm_pci_pwrctrl_slot_power_off,
> slot);
> if (ret)
> - goto err_regulator_disable;
> + return ret;
>
> clk = devm_clk_get_optional_enabled(dev, NULL);
> if (IS_ERR(clk)) {
> @@ -70,13 +71,6 @@ static int pci_pwrctrl_slot_probe(struct platform_device *pdev)
> return dev_err_probe(dev, ret, "Failed to register pwrctrl driver\n");
>
> return 0;
> -
> -err_regulator_disable:
> - regulator_bulk_disable(slot->num_supplies, slot->supplies);
> -err_regulator_free:
> - regulator_bulk_free(slot->num_supplies, slot->supplies);
> -
> - return ret;
> }
>
> static const struct of_device_id pci_pwrctrl_slot_of_match[] = {
> --
> 2.43.0
>
prev parent reply other threads:[~2025-08-13 19:35 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-13 15:56 [PATCH v2] PCI/pwrctrl: Fix double cleanup on devm_add_action_or_reset() failure Geert Uytterhoeven
2025-08-13 19:35 ` Bjorn Helgaas [this message]
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=20250813193510.GA287916@bhelgaas \
--to=helgaas@kernel.org \
--cc=bartosz.golaszewski@linaro.org \
--cc=bhelgaas@google.com \
--cc=brgl@bgdev.pl \
--cc=geert+renesas@glider.be \
--cc=kwilczynski@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=linux-renesas-soc@vger.kernel.org \
--cc=mani@kernel.org \
--cc=manivannan.sadhasivam@linaro.org \
--cc=marek.vasut+renesas@mailbox.org \
/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