* [PATCH] power: sequencing: pcie-m2: Fix leaking array from of_regulator_bulk_get_all()
@ 2026-09-30 16:10 Alexey Charkov
2026-09-30 16:21 ` sashiko-bot
2026-10-01 7:52 ` Bartosz Golaszewski
0 siblings, 2 replies; 3+ messages in thread
From: Alexey Charkov @ 2026-09-30 16:10 UTC (permalink / raw)
To: Manivannan Sadhasivam, Bartosz Golaszewski
Cc: Bartosz Golaszewski, Manivannan Sadhasivam, linux-pci, linux-pm,
linux-kernel, stable, Alexey Charkov
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.
pwrseq-pcie-m2.c never did, leading to a memory leak.
Add an explicit kfree() for the consumers array.
Cc: stable@vger.kernel.org
Fixes: 52e7b5bd62ba ("power: sequencing: Add the Power Sequencing driver for the PCIe M.2 connectors")
Signed-off-by: Alexey Charkov <alchark@flipper.net>
---
Split out from [1] for easier application per Mark's feedback
[1] https://lore.kernel.org/all/20260929-regulator-get-all-v1-0-e887c66a47f1@flipper.net/
---
drivers/power/sequencing/pwrseq-pcie-m2.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/power/sequencing/pwrseq-pcie-m2.c b/drivers/power/sequencing/pwrseq-pcie-m2.c
index 91916768e922..0febe4b3d980 100644
--- a/drivers/power/sequencing/pwrseq-pcie-m2.c
+++ b/drivers/power/sequencing/pwrseq-pcie-m2.c
@@ -613,6 +613,7 @@ static int pwrseq_pcie_m2_probe(struct platform_device *pdev)
mutex_destroy(&ctx->list_lock);
err_free_regulators:
regulator_bulk_free(ctx->num_vregs, ctx->regs);
+ kfree(ctx->regs);
return ret;
}
@@ -626,6 +627,7 @@ static void pwrseq_pcie_m2_remove(struct platform_device *pdev)
mutex_destroy(&ctx->list_lock);
regulator_bulk_free(ctx->num_vregs, ctx->regs);
+ kfree(ctx->regs);
}
static const struct of_device_id pwrseq_pcie_m2_of_match[] = {
---
base-commit: 6c2cb8b8b843d216ab549b678a0d8831c43153e0
change-id: 20260930-m2-pwrseq-kfree-78bcbc3b6f02
Best regards,
--
Alexey Charkov <alchark@flipper.net>
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] power: sequencing: pcie-m2: Fix leaking array from of_regulator_bulk_get_all()
2026-09-30 16:10 [PATCH] power: sequencing: pcie-m2: Fix leaking array from of_regulator_bulk_get_all() Alexey Charkov
@ 2026-09-30 16:21 ` sashiko-bot
2026-10-01 7:52 ` Bartosz Golaszewski
1 sibling, 0 replies; 3+ messages in thread
From: sashiko-bot @ 2026-09-30 16:21 UTC (permalink / raw)
To: Alexey Charkov; +Cc: linux-pci
> 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.
> pwrseq-pcie-m2.c never did, leading to a memory leak.
>
> Add an explicit kfree() for the consumers array.
>
> Cc: stable@vger.kernel.org
> Fixes: 52e7b5bd62ba ("power: sequencing: Add the Power Sequencing driver for the PCIe M.2 connectors")
> Signed-off-by: Alexey Charkov <alchark@flipper.net>
Sashiko has reviewed this patch and found no issues. It looks great!
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260930-m2-pwrseq-kfree-v1-1-82678b02c126@flipper.net?part=1
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] power: sequencing: pcie-m2: Fix leaking array from of_regulator_bulk_get_all()
2026-09-30 16:10 [PATCH] power: sequencing: pcie-m2: Fix leaking array from of_regulator_bulk_get_all() Alexey Charkov
2026-09-30 16:21 ` sashiko-bot
@ 2026-10-01 7:52 ` Bartosz Golaszewski
1 sibling, 0 replies; 3+ messages in thread
From: Bartosz Golaszewski @ 2026-10-01 7:52 UTC (permalink / raw)
To: Manivannan Sadhasivam, Bartosz Golaszewski, Alexey Charkov
Cc: Bartosz Golaszewski, Manivannan Sadhasivam, linux-pci, linux-pm,
linux-kernel, stable
On Wed, 30 Sep 2026 20:10:21 +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.
> pwrseq-pcie-m2.c never did, leading to a memory leak.
>
> Add an explicit kfree() for the consumers array.
>
>
> [...]
Applied, thanks!
[1/1] power: sequencing: pcie-m2: Fix leaking array from of_regulator_bulk_get_all()
https://git.kernel.org/brgl/c/0d6c5794fd633427f0d4ad8b51d94061295649da
Best regards,
--
Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-10-01 7:52 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-30 16:10 [PATCH] power: sequencing: pcie-m2: Fix leaking array from of_regulator_bulk_get_all() Alexey Charkov
2026-09-30 16:21 ` sashiko-bot
2026-10-01 7:52 ` Bartosz Golaszewski
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox