[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250626144915.GD213144@ziepe.ca>
Date: Thu, 26 Jun 2025 11:49:15 -0300
From: Jason Gunthorpe <jgg@...pe.ca>
To: Jarkko Sakkinen <jarkko@...nel.org>
Cc: linux-kernel@...r.kernel.org, keyrings@...r.kernel.org,
Jarkko Sakkinen <jarkko.sakkinen@...nsys.com>,
Peter Huewe <peterhuewe@....de>,
James Bottomley <James.Bottomley@...senpartnership.com>,
Mimi Zohar <zohar@...ux.ibm.com>,
David Howells <dhowells@...hat.com>,
Paul Moore <paul@...l-moore.com>, James Morris <jmorris@...ei.org>,
"Serge E. Hallyn" <serge@...lyn.com>,
"open list:TPM DEVICE DRIVER" <linux-integrity@...r.kernel.org>,
"open list:SECURITY SUBSYSTEM" <linux-security-module@...r.kernel.org>
Subject: Re: [PATCH] tpm: Create cleanup class for tpm_buf
On Thu, Jun 26, 2025 at 12:37:56AM +0300, Jarkko Sakkinen wrote:
> @@ -323,7 +323,7 @@ unsigned long tpm1_calc_ordinal_duration(struct tpm_chip *chip, u32 ordinal)
> */
> static int tpm1_startup(struct tpm_chip *chip)
> {
> - struct tpm_buf buf;
> + CLASS(tpm_buf, buf)();
> int rc;
>
> dev_info(&chip->dev, "starting up the TPM manually\n");
> @@ -335,7 +335,6 @@ static int tpm1_startup(struct tpm_chip *chip)
> tpm_buf_append_u16(&buf, TPM_ST_CLEAR);
>
> rc = tpm_transmit_cmd(chip, &buf, 0, "attempting to start the TPM");
> - tpm_buf_destroy(&buf);
> return rc;
> }
So, Linus has spoken negatively about just converting existing code to
use cleanup.h, fearful it would introduce more bugs.
I would certainly split this into more patches, and it would be nice
if something mechanical like coccinelle could do the change.
At least I would add the class and drop the tpm_buf_destroy() as one
patch, and another would be to cleanup any empty gotos.
Also, I think the style guide for cleanup.h is to not use the
variable block, so it should be more like:
CLASS(tpm_buf, buf)();
if (!tpm_buf)
return -ENOMEM;
AFAICT, but that seems to be some kind of tribal knowledge.
Jason
Powered by blists - more mailing lists