Re: [PATCH v4] tpm: Managed allocations for tpm_buf instances
From: Jason Gunthorpe
Date: Wed Jul 02 2025 - 08:57:41 EST
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