Skip to content

Commit ab81f2f

Browse files
geertubjorn-helgaas
authored andcommitted
PCI/pwrctrl: Fix double cleanup on devm_add_action_or_reset() failure
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: 75996c9 ("PCI/pwrctrl: Add pwrctrl driver for PCI slots") Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com> Tested-by: Marek Vasut <marek.vasut+renesas@mailbox.org> # V4H Sparrow Hawk Reviewed-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org> Reviewed-by: Marek Vasut <marek.vasut+renesas@mailbox.org> Acked-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org> Link: https://patch.msgid.link/7b1386e6162e70e6d631c87f6323d2ab971bc1c5.1755100324.git.geert+renesas@glider.be
1 parent 8f5ae30 commit ab81f2f

1 file changed

Lines changed: 3 additions & 9 deletions

File tree

drivers/pci/pwrctrl/slot.c

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,14 @@ static int pci_pwrctrl_slot_probe(struct platform_device *pdev)
4949
ret = regulator_bulk_enable(slot->num_supplies, slot->supplies);
5050
if (ret < 0) {
5151
dev_err_probe(dev, ret, "Failed to enable slot regulators\n");
52-
goto err_regulator_free;
52+
regulator_bulk_free(slot->num_supplies, slot->supplies);
53+
return ret;
5354
}
5455

5556
ret = devm_add_action_or_reset(dev, devm_pci_pwrctrl_slot_power_off,
5657
slot);
5758
if (ret)
58-
goto err_regulator_disable;
59+
return ret;
5960

6061
clk = devm_clk_get_optional_enabled(dev, NULL);
6162
if (IS_ERR(clk)) {
@@ -70,13 +71,6 @@ static int pci_pwrctrl_slot_probe(struct platform_device *pdev)
7071
return dev_err_probe(dev, ret, "Failed to register pwrctrl driver\n");
7172

7273
return 0;
73-
74-
err_regulator_disable:
75-
regulator_bulk_disable(slot->num_supplies, slot->supplies);
76-
err_regulator_free:
77-
regulator_bulk_free(slot->num_supplies, slot->supplies);
78-
79-
return ret;
8074
}
8175

8276
static const struct of_device_id pci_pwrctrl_slot_of_match[] = {

0 commit comments

Comments
 (0)