X86 platform drivers
 help / color / mirror / Atom feed
From: "Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>
To: Rosen Penev <rosenp@gmail.com>
Cc: platform-driver-x86@vger.kernel.org,
	Hans de Goede <hansg@kernel.org>,  Kees Cook <kees@kernel.org>,
	"Gustavo A. R. Silva" <gustavoars@kernel.org>,
	 open list <linux-kernel@vger.kernel.org>,
	 "open list:KERNEL HARDENING (not covered by other
	areas):Keyword:b__counted_by(_le|_be|_ptr)?b"
	<linux-hardening@vger.kernel.org>
Subject: Re: [PATCHv2] platform/x86/intel/tpmi/plr: allocate die_info with plr
Date: Thu, 21 May 2026 13:33:05 +0300 (EEST)	[thread overview]
Message-ID: <d8ae7a61-c7ef-6b23-7d9d-e5dd35c86dcf@linux.intel.com> (raw)
In-Reply-To: <20260521014608.1356671-1-rosenp@gmail.com>

On Wed, 20 May 2026, Rosen Penev wrote:

> Simplifies allocations slightly.
> 
> Add __counted_by for extra runtime analysis.
> 
> Signed-off-by: Rosen Penev <rosenp@gmail.com>
> ---
>  v2: Rebase.
>  drivers/platform/x86/intel/plr_tpmi.c | 12 ++----------
>  1 file changed, 2 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/platform/x86/intel/plr_tpmi.c b/drivers/platform/x86/intel/plr_tpmi.c
> index 8faecc311038..66220fadf670 100644
> --- a/drivers/platform/x86/intel/plr_tpmi.c
> +++ b/drivers/platform/x86/intel/plr_tpmi.c
> @@ -58,11 +58,11 @@ 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 notifier_block nb;
>  	struct mutex lock;	/* Protect access to dbgfs_dir */
> +	struct tpmi_plr_die die_info[] __counted_by(num_dies);
>  };
>  
>  static const char * const plr_coarse_reasons[] = {
> @@ -305,7 +305,7 @@ 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);

Hi,

I'd prefer to have devm_kzalloc_flex() be added before continuing with 
changes like this. Last time I mentioned it, you washed your hands about 
adding it and moved the responsability to linux-hardening folks. (In case 
you didn't know, devm_kzalloc_flex() could be added even by you!)

Alternatively, I might accept a good explanation why that cannot be done 
or is not a good idea to have consistent interface for non-devm vs devm?

>  	if (!plr)
>  		return -ENOMEM;
>  
> @@ -315,13 +315,6 @@ static int intel_plr_probe(struct auxiliary_device *auxdev, const struct auxilia
>  
>  	intel_plr_register_notifier(&plr->nb);
>  
> -	plr->die_info = devm_kcalloc(&auxdev->dev, num_resources, sizeof(*plr->die_info),
> -				     GFP_KERNEL);
> -	if (!plr->die_info) {
> -		err = -ENOMEM;
> -		goto err_notify;
> -	}
> -
>  	plr->num_dies = num_resources;
>  	plr->dbgfs_dir = debugfs_create_dir("plr", dentry);
>  	plr->auxdev = auxdev;
> @@ -361,7 +354,6 @@ static int intel_plr_probe(struct auxiliary_device *auxdev, const struct auxilia
>  
>  err:
>  	debugfs_remove_recursive(plr->dbgfs_dir);
> -err_notify:
>  	intel_plr_unregister_notifier(&plr->nb);
>  
>  	return err;
> 

-- 
 i.


      reply	other threads:[~2026-05-21 10:33 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-21  1:46 [PATCHv2] platform/x86/intel/tpmi/plr: allocate die_info with plr Rosen Penev
2026-05-21 10:33 ` Ilpo Järvinen [this message]

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=d8ae7a61-c7ef-6b23-7d9d-e5dd35c86dcf@linux.intel.com \
    --to=ilpo.jarvinen@linux.intel.com \
    --cc=gustavoars@kernel.org \
    --cc=hansg@kernel.org \
    --cc=kees@kernel.org \
    --cc=linux-hardening@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=platform-driver-x86@vger.kernel.org \
    --cc=rosenp@gmail.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