| Message ID | 20260930-m2-pwrseq-kfree-v1-1-82678b02c126@flipper.net |
|---|---|
| State | New |
| Headers | show |
| Series | power: sequencing: pcie-m2: Fix leaking array from of_regulator_bulk_get_all() | expand |
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,
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[] = {
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(+) --- base-commit: 6c2cb8b8b843d216ab549b678a0d8831c43153e0 change-id: 20260930-m2-pwrseq-kfree-78bcbc3b6f02 Best regards, -- Alexey Charkov <alchark@flipper.net>