[PATCH v4] tpm: Managed allocations for tpm_buf instances

Jason Gunthorpe jgg at ziepe.ca
Wed Jul 2 12:57:25 UTC 2025


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;

Jason



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