]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
PCI: brcmstb: Fix error path after a call to regulator_bulk_get()
authorJim Quinlan <james.quinlan@broadcom.com>
Fri, 14 Feb 2025 17:39:32 +0000 (12:39 -0500)
committerKrzysztof Wilczyński <kwilczynski@kernel.org>
Tue, 4 Mar 2025 16:00:20 +0000 (16:00 +0000)
If the regulator_bulk_get() returns an error and no regulators
are created, we need to set their number to zero.

If we don't do this and the PCIe link up fails, a call to the
regulator_bulk_free() will result in a kernel panic.

While at it, print the error value, as we cannot return an error
upwards as the kernel will WARN() on an error from add_bus().

Fixes: 9e6be018b263 ("PCI: brcmstb: Enable child bus device regulators from DT")
Signed-off-by: Jim Quinlan <james.quinlan@broadcom.com>
Reviewed-by: Florian Fainelli <florian.fainelli@broadcom.com>
Link: https://lore.kernel.org/r/20250214173944.47506-5-james.quinlan@broadcom.com
[kwilczynski: commit log, use comma in the message to match style with
other similar messages]
Signed-off-by: Krzysztof Wilczyński <kwilczynski@kernel.org>
drivers/pci/controller/pcie-brcmstb.c

index 4e53d0da510b06a52ee5296c22aa9179530f691d..7d1c6dc599da7394c9e0c34b013257e51f3ac415 100644 (file)
@@ -1416,7 +1416,8 @@ static int brcm_pcie_add_bus(struct pci_bus *bus)
 
                ret = regulator_bulk_get(dev, sr->num_supplies, sr->supplies);
                if (ret) {
-                       dev_info(dev, "No regulators for downstream device\n");
+                       dev_info(dev, "Did not get regulators, err=%d\n", ret);
+                       pcie->sr = NULL;
                        goto no_regulators;
                }