From: Alexey Charkov <alchark@flipper.net>
To: "Liam Girdwood" <lgirdwood@gmail.com>,
"Mark Brown" <broonie@kernel.org>,
"Corentin Labbe" <clabbe@baylibre.com>,
"Manivannan Sadhasivam" <mani@kernel.org>,
"Bartosz Golaszewski" <brgl@kernel.org>,
"Bjorn Helgaas" <bhelgaas@google.com>,
"Krzysztof Wilczyński" <kwilczynski@kernel.org>
Cc: linux-kernel@vger.kernel.org,
Manivannan Sadhasivam <manivannan.sadhasivam@oss.qualcomm.com>,
Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>,
linux-pci@vger.kernel.org, linux-pm@vger.kernel.org,
Alexey Charkov <alchark@flipper.net>
Subject: [PATCH 2/4] regulator: of: state who owns the array from of_regulator_bulk_get_all()
Date: Tue, 29 Sep 2026 14:05:47 +0400 [thread overview]
Message-ID: <20260929-regulator-get-all-v1-2-e887c66a47f1@flipper.net> (raw)
In-Reply-To: <20260929-regulator-get-all-v1-0-e887c66a47f1@flipper.net>
of_regulator_bulk_get_all() allocates the consumer array and hands it to
the caller, but never said so. Its own error path frees the array, while
regulator_bulk_free() only puts the regulators, so both callers release
the regulators and leak the array.
Spell the contract out in the kerneldoc.
Signed-off-by: Alexey Charkov <alchark@flipper.net>
---
drivers/regulator/of_regulator.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/drivers/regulator/of_regulator.c b/drivers/regulator/of_regulator.c
index 785b7a11dfc6..09e26febfc83 100644
--- a/drivers/regulator/of_regulator.c
+++ b/drivers/regulator/of_regulator.c
@@ -929,6 +929,11 @@ static int is_supply_name(const char *name)
* before returning to the caller, and @consumers will not be
* changed.
*
+ * On success the array is allocated here and handed to the caller, which
+ * owns it from then on: release the regulators with regulator_bulk_free()
+ * and free the array itself with kfree(). The supply names live in the
+ * same allocation, so they are gone once the array is freed.
+ *
* Return: Number of regulators on success, or a negative error number
* on failure.
*/
--
2.55.0
next prev parent reply other threads:[~2026-09-29 10:06 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-29 10:05 [PATCH 0/4] regulator: of: Fixes to of_regulator_bulk_get_all() Alexey Charkov
2026-09-29 10:05 ` [PATCH 1/4] regulator: of: fill in supply names in of_regulator_bulk_get_all() Alexey Charkov
2026-09-29 10:05 ` Alexey Charkov [this message]
2026-09-29 10:05 ` [PATCH 3/4] power: sequencing: pcie-m2: Fix leaking array from of_regulator_bulk_get_all() Alexey Charkov
2026-09-29 10:05 ` [PATCH 4/4] PCI/pwrctrl: generic: " Alexey Charkov
2026-10-01 7:52 ` Bartosz Golaszewski
2026-10-01 16:46 ` Bjorn Helgaas
2026-10-01 16:51 ` Bjorn Helgaas
2026-09-29 15:31 ` [PATCH 0/4] regulator: of: Fixes to of_regulator_bulk_get_all() Mark Brown
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260929-regulator-get-all-v1-2-e887c66a47f1@flipper.net \
--to=alchark@flipper.net \
--cc=bartosz.golaszewski@oss.qualcomm.com \
--cc=bhelgaas@google.com \
--cc=brgl@kernel.org \
--cc=broonie@kernel.org \
--cc=clabbe@baylibre.com \
--cc=kwilczynski@kernel.org \
--cc=lgirdwood@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=mani@kernel.org \
--cc=manivannan.sadhasivam@oss.qualcomm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®