Re: [PATCH 4/4] PCI/pwrctrl: generic: Fix leaking array from of_regulator_bulk_get_all()
From: Bjorn Helgaas
Date: Thu Oct 01 2026 - 13:01:12 EST
On Thu, Oct 01, 2026 at 11:46:11AM -0500, Bjorn Helgaas wrote:
> On Tue, Sep 29, 2026 at 02:05:49PM +0400, Alexey Charkov wrote:
> > of_regulator_bulk_get_all() allocates the consumers array and hands it to
> > the caller, who is expected to free it at an appropriate time.
> > PCI pwrctrl never did, leading to a memory leak.
> >
> > Add an explicit kfree() for the consumers array.
> >
> > Cc: stable@xxxxxxxxxxxxxxx
> > Fixes: 75996c92f4de ("PCI/pwrctrl: Add pwrctrl driver for PCI slots")
> > Signed-off-by: Alexey Charkov <alchark@xxxxxxxxxxx>
>
> Acked-by: Bjorn Helgaas <bhelgaas@xxxxxxxxxx>
>
> I assume this will be merged via a non-PCI tree.
After reading farther through my email, I see this was posted
separately, so I applied that to pci/pwrctrl for v7.4.
> > ---
> > drivers/pci/pwrctrl/generic.c | 1 +
> > 1 file changed, 1 insertion(+)
> >
> > diff --git a/drivers/pci/pwrctrl/generic.c b/drivers/pci/pwrctrl/generic.c
> > index d56171e0ee24..4b6cbbb52248 100644
> > --- a/drivers/pci/pwrctrl/generic.c
> > +++ b/drivers/pci/pwrctrl/generic.c
> > @@ -63,6 +63,7 @@ static void devm_slot_pwrctrl_release(void *data)
> > struct slot_pwrctrl *slot = data;
> >
> > regulator_bulk_free(slot->num_supplies, slot->supplies);
> > + kfree(slot->supplies);
> > }
> >
> > static int slot_pwrctrl_probe(struct platform_device *pdev)
> >
> > --
> > 2.55.0
> >