* Re: [PATCH] platform/x86/intel/tpmi/plr: allocate die_info with plr
[not found] <20260430225309.117557-1-rosenp@gmail.com>
@ 2026-05-11 16:31 ` Ilpo Järvinen
2026-05-12 3:21 ` Rosen Penev
0 siblings, 1 reply; 2+ messages in thread
From: Ilpo Järvinen @ 2026-05-11 16:31 UTC (permalink / raw)
To: Rosen Penev
Cc: platform-driver-x86, Hans de Goede, Kees Cook,
Gustavo A. R. Silva, open list, open list:KERNEL HARDENING
On Thu, 30 Apr 2026, Rosen Penev wrote:
> Simplifies allocations slightly.
>
> Add __counted_by for extra runtime analysis.
>
> Signed-off-by: Rosen Penev <rosenp@gmail.com>
> ---
> drivers/platform/x86/intel/plr_tpmi.c | 9 ++-------
> 1 file changed, 2 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/platform/x86/intel/plr_tpmi.c b/drivers/platform/x86/intel/plr_tpmi.c
> index 05727169f49c..2fd27e80bc1f 100644
> --- a/drivers/platform/x86/intel/plr_tpmi.c
> +++ b/drivers/platform/x86/intel/plr_tpmi.c
> @@ -57,9 +57,9 @@ struct tpmi_plr_die {
>
> struct tpmi_plr {
> struct dentry *dbgfs_dir;
> - struct tpmi_plr_die *die_info;
> int num_dies;
> struct auxiliary_device *auxdev;
> + struct tpmi_plr_die die_info[] __counted_by(num_dies);
> };
>
> static const char * const plr_coarse_reasons[] = {
> @@ -278,15 +278,10 @@ static int intel_plr_probe(struct auxiliary_device *auxdev, const struct auxilia
> if (!num_resources)
> return -EINVAL;
>
> - plr = devm_kzalloc(&auxdev->dev, sizeof(*plr), GFP_KERNEL);
> + plr = devm_kzalloc(&auxdev->dev, struct_size(plr, die_info, num_resources), GFP_KERNEL);
Is there some particular reason why we don't have devm_kzalloc_flex()
other than that nobody has yet bothered to added one.
One of the most annoying thing with the various alloc APIs is that devm_*
variants seem to never keep up with them. It would be nice if there would
be some generic solution that when somebody decides a new alloc api func,
the corresponding devm counterpart would be auto-generated for it.
--
i.
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] platform/x86/intel/tpmi/plr: allocate die_info with plr
2026-05-11 16:31 ` [PATCH] platform/x86/intel/tpmi/plr: allocate die_info with plr Ilpo Järvinen
@ 2026-05-12 3:21 ` Rosen Penev
0 siblings, 0 replies; 2+ messages in thread
From: Rosen Penev @ 2026-05-12 3:21 UTC (permalink / raw)
To: Ilpo Järvinen
Cc: platform-driver-x86, Hans de Goede, Kees Cook,
Gustavo A. R. Silva, open list, open list:KERNEL HARDENING
On Mon, May 11, 2026 at 9:31 AM Ilpo Järvinen
<ilpo.jarvinen@linux.intel.com> wrote:
>
> On Thu, 30 Apr 2026, Rosen Penev wrote:
>
> > Simplifies allocations slightly.
> >
> > Add __counted_by for extra runtime analysis.
> >
> > Signed-off-by: Rosen Penev <rosenp@gmail.com>
> > ---
> > drivers/platform/x86/intel/plr_tpmi.c | 9 ++-------
> > 1 file changed, 2 insertions(+), 7 deletions(-)
> >
> > diff --git a/drivers/platform/x86/intel/plr_tpmi.c b/drivers/platform/x86/intel/plr_tpmi.c
> > index 05727169f49c..2fd27e80bc1f 100644
> > --- a/drivers/platform/x86/intel/plr_tpmi.c
> > +++ b/drivers/platform/x86/intel/plr_tpmi.c
> > @@ -57,9 +57,9 @@ struct tpmi_plr_die {
> >
> > struct tpmi_plr {
> > struct dentry *dbgfs_dir;
> > - struct tpmi_plr_die *die_info;
> > int num_dies;
> > struct auxiliary_device *auxdev;
> > + struct tpmi_plr_die die_info[] __counted_by(num_dies);
> > };
> >
> > static const char * const plr_coarse_reasons[] = {
> > @@ -278,15 +278,10 @@ static int intel_plr_probe(struct auxiliary_device *auxdev, const struct auxilia
> > if (!num_resources)
> > return -EINVAL;
> >
> > - plr = devm_kzalloc(&auxdev->dev, sizeof(*plr), GFP_KERNEL);
> > + plr = devm_kzalloc(&auxdev->dev, struct_size(plr, die_info, num_resources), GFP_KERNEL);
>
> Is there some particular reason why we don't have devm_kzalloc_flex()
> other than that nobody has yet bothered to added one.
I'm not up to date with the hardening people. Anyway when it does,
this will get transformed by a treewide patch.
>
> One of the most annoying thing with the various alloc APIs is that devm_*
> variants seem to never keep up with them. It would be nice if there would
> be some generic solution that when somebody decides a new alloc api func,
> the corresponding devm counterpart would be auto-generated for it.
>
> --
> i.
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-05-12 3:21 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <20260430225309.117557-1-rosenp@gmail.com>
2026-05-11 16:31 ` [PATCH] platform/x86/intel/tpmi/plr: allocate die_info with plr Ilpo Järvinen
2026-05-12 3:21 ` Rosen Penev
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox