[PATCH v4] tpm: Managed allocations for tpm_buf instances

Jarkko Sakkinen jarkko at kernel.org
Wed Jul 2 22:42:09 UTC 2025


On Wed, Jul 02, 2025 at 09:57:25AM -0300, Jason Gunthorpe wrote:
> On Tue, Jul 01, 2025 at 05:51:35PM +0300, Jarkko Sakkinen wrote:
> > @@ -32,28 +32,30 @@ struct tpm_readpubek_out {
> >  static ssize_t pubek_show(struct device *dev, struct device_attribute *attr,
> >  			  char *buf)
> >  {
> > -	struct tpm_buf tpm_buf;
> > +	struct tpm_buf *tpm_buf __free(kfree) = NULL;
> >  	struct tpm_readpubek_out *out;
> >  	int i;
> >  	char *str = buf;
> >  	struct tpm_chip *chip = to_tpm_chip(dev);
> >  	char anti_replay[20];
> >  
> > +	tpm_buf = tpm_buf_alloc();
> > +	if (!tpm_buf)
> > +		return -ENOMEM;
> 
> apprently this isn't the style guide, you are supposed to write:
> 
>   	char anti_replay[20];
> 
> 	struct tpm_buf *tpm_buf __free(kfree) =  tpm_buf_alloc();
> 	if (!tpm_buf)
> 		return -ENOMEM;

Sounds fair to me. I'll shift to this direction in the next revision.

> 
> Jason

BR, Jarkko

BR, Jarkko



More information about the Linux-security-module-archive mailing list