* [PATCH] regulator: da9063: kzalloc + kcalloc to kzalloc
@ 2026-03-11 0:41 Rosen Penev
2026-03-14 21:58 ` Mark Brown
0 siblings, 1 reply; 2+ messages in thread
From: Rosen Penev @ 2026-03-11 0:41 UTC (permalink / raw)
To: dri-devel
Cc: Support Opensource, Liam Girdwood, Mark Brown, Kees Cook,
Gustavo A. R. Silva,
open list:VOLTAGE AND CURRENT REGULATOR FRAMEWORK,
open list:KERNEL HARDENING (not covered by other areas):Keyword:b__counted_by(_le|_be)?b
Reduce main allocation to a single kzalloc call by using a flexible
array member.
Allows using __counted_by for extra runtime analysis.
Signed-off-by: Rosen Penev <rosenp@gmail.com>
---
drivers/regulator/da9063-regulator.c | 9 ++-------
1 file changed, 2 insertions(+), 7 deletions(-)
diff --git a/drivers/regulator/da9063-regulator.c b/drivers/regulator/da9063-regulator.c
index 9d369cc45d41..bf34ea440d77 100644
--- a/drivers/regulator/da9063-regulator.c
+++ b/drivers/regulator/da9063-regulator.c
@@ -67,7 +67,7 @@ struct da9063_regulator_data {
struct da9063_regulators_pdata {
unsigned int n_regulators;
- struct da9063_regulator_data *regulator_data;
+ struct da9063_regulator_data regulator_data[] __counted_by(n_regulators);
};
/* Regulator capabilities and registers description */
@@ -857,15 +857,10 @@ static struct da9063_regulators_pdata *da9063_parse_regulators_dt(
return ERR_PTR(-EINVAL);
}
- pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL);
+ pdata = devm_kzalloc(&pdev->dev, struct_size(pdata, regulator_data, num), GFP_KERNEL);
if (!pdata)
return ERR_PTR(-ENOMEM);
- pdata->regulator_data = devm_kcalloc(&pdev->dev,
- num, sizeof(*pdata->regulator_data),
- GFP_KERNEL);
- if (!pdata->regulator_data)
- return ERR_PTR(-ENOMEM);
pdata->n_regulators = num;
n = 0;
--
2.53.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] regulator: da9063: kzalloc + kcalloc to kzalloc
2026-03-11 0:41 [PATCH] regulator: da9063: kzalloc + kcalloc to kzalloc Rosen Penev
@ 2026-03-14 21:58 ` Mark Brown
0 siblings, 0 replies; 2+ messages in thread
From: Mark Brown @ 2026-03-14 21:58 UTC (permalink / raw)
To: Rosen Penev
Cc: Support Opensource, Liam Girdwood, Kees Cook, Gustavo A. R. Silva,
linux-kernel, linux-hardening
On Tue, 10 Mar 2026 17:41:59 -0700, Rosen Penev wrote:
> regulator: da9063: kzalloc + kcalloc to kzalloc
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator.git for-7.1
Thanks!
[1/1] regulator: da9063: kzalloc + kcalloc to kzalloc
https://git.kernel.org/broonie/misc/c/cf4812898b58
All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying
to this mail.
Thanks,
Mark
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-03-16 1:38 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-11 0:41 [PATCH] regulator: da9063: kzalloc + kcalloc to kzalloc Rosen Penev
2026-03-14 21:58 ` Mark Brown
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox