Message ID | a820eaf8c77ca4fde50fc170f535de4b28c82a2d.1677322706.git.christophe.jaillet@wanadoo.fr (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | tpm_crb: Fix an error handling path in crb_acpi_add() | expand |
Le 25/02/2023 à 11:58, Christophe JAILLET a écrit : > Some error paths don't call acpi_put_table() before returning. > Branch to the correct place instead of doing some direct return. > > Fixes: 4d2732882703 ("tpm_crb: Add support for CRB devices based on Pluton") > Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr> > --- > drivers/char/tpm/tpm_crb.c | 5 +++-- > 1 file changed, 3 insertions(+), 2 deletions(-) > > diff --git a/drivers/char/tpm/tpm_crb.c b/drivers/char/tpm/tpm_crb.c > index 99698ee1a744..f7068bd8b3d0 100644 > --- a/drivers/char/tpm/tpm_crb.c > +++ b/drivers/char/tpm/tpm_crb.c > @@ -771,12 +771,13 @@ static int crb_acpi_add(struct acpi_device *device) > FW_BUG "TPM2 ACPI table has wrong size %u for start method type %d\n", > buf->header.length, > ACPI_TPM2_COMMAND_BUFFER_WITH_PLUTON); > - return -EINVAL; > + rc = -EINVAL; > + goto out; > } > crb_pluton = ACPI_ADD_PTR(struct tpm2_crb_pluton, buf, sizeof(*buf)); > rc = crb_map_pluton(dev, priv, buf, crb_pluton); > if (rc) > - return rc; > + goto out; > } > > priv->sm = sm; Hi, polite reminder. While re-looking at it, the 3rd parameter of crb_map_pluton() (i.e. buf) looks unused and could be removed if it makes sense to you. CJ
On Sun, Aug 20, 2023 at 08:21:47AM +0200, Christophe JAILLET wrote: > Le 25/02/2023 à 11:58, Christophe JAILLET a écrit : > > Some error paths don't call acpi_put_table() before returning. > > Branch to the correct place instead of doing some direct return. > > > > Fixes: 4d2732882703 ("tpm_crb: Add support for CRB devices based on Pluton") > > Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr> > > --- > > drivers/char/tpm/tpm_crb.c | 5 +++-- > > 1 file changed, 3 insertions(+), 2 deletions(-) > > > > diff --git a/drivers/char/tpm/tpm_crb.c b/drivers/char/tpm/tpm_crb.c > > index 99698ee1a744..f7068bd8b3d0 100644 > > --- a/drivers/char/tpm/tpm_crb.c > > +++ b/drivers/char/tpm/tpm_crb.c > > @@ -771,12 +771,13 @@ static int crb_acpi_add(struct acpi_device *device) > > FW_BUG "TPM2 ACPI table has wrong size %u for start method type %d\n", > > buf->header.length, > > ACPI_TPM2_COMMAND_BUFFER_WITH_PLUTON); > > - return -EINVAL; > > + rc = -EINVAL; > > + goto out; > > } > > crb_pluton = ACPI_ADD_PTR(struct tpm2_crb_pluton, buf, sizeof(*buf)); > > rc = crb_map_pluton(dev, priv, buf, crb_pluton); > > if (rc) > > - return rc; > > + goto out; > > } > > priv->sm = sm; > > Hi, > > polite reminder. > > While re-looking at it, the 3rd parameter of crb_map_pluton() (i.e. buf) > looks unused and could be removed if it makes sense to you. For the original patch: ACKed-by: Matthew Garrett <mgarrett@aurora.tech> I'm actually re-working the pluton mapping code because right now it's impossible to use localities because the ACPI table is unhelpful and I think that can be worked around.
On Sun Aug 20, 2023 at 9:21 AM EEST, Christophe JAILLET wrote: > Le 25/02/2023 à 11:58, Christophe JAILLET a écrit : > > Some error paths don't call acpi_put_table() before returning. > > Branch to the correct place instead of doing some direct return. > > > > Fixes: 4d2732882703 ("tpm_crb: Add support for CRB devices based on Pluton") > > Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr> > > --- > > drivers/char/tpm/tpm_crb.c | 5 +++-- > > 1 file changed, 3 insertions(+), 2 deletions(-) > > > > diff --git a/drivers/char/tpm/tpm_crb.c b/drivers/char/tpm/tpm_crb.c > > index 99698ee1a744..f7068bd8b3d0 100644 > > --- a/drivers/char/tpm/tpm_crb.c > > +++ b/drivers/char/tpm/tpm_crb.c > > @@ -771,12 +771,13 @@ static int crb_acpi_add(struct acpi_device *device) > > FW_BUG "TPM2 ACPI table has wrong size %u for start method type %d\n", > > buf->header.length, > > ACPI_TPM2_COMMAND_BUFFER_WITH_PLUTON); > > - return -EINVAL; > > + rc = -EINVAL; > > + goto out; > > } > > crb_pluton = ACPI_ADD_PTR(struct tpm2_crb_pluton, buf, sizeof(*buf)); > > rc = crb_map_pluton(dev, priv, buf, crb_pluton); > > if (rc) > > - return rc; > > + goto out; > > } > > > > priv->sm = sm; > > Hi, > > polite reminder. > > While re-looking at it, the 3rd parameter of crb_map_pluton() (i.e. buf) > looks unused and could be removed if it makes sense to you. This AFAIK went to Linux v6.2 already. BR, Jarkko
rn Tue Aug 22, 2023 at 2:28 PM EEST, Jarkko Sakkinen wrote: > On Sun Aug 20, 2023 at 9:21 AM EEST, Christophe JAILLET wrote: > > Le 25/02/2023 à 11:58, Christophe JAILLET a écrit : > > > Some error paths don't call acpi_put_table() before returning. > > > Branch to the correct place instead of doing some direct return. > > > > > > Fixes: 4d2732882703 ("tpm_crb: Add support for CRB devices based on Pluton") > > > Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr> > > > --- > > > drivers/char/tpm/tpm_crb.c | 5 +++-- > > > 1 file changed, 3 insertions(+), 2 deletions(-) > > > > > > diff --git a/drivers/char/tpm/tpm_crb.c b/drivers/char/tpm/tpm_crb.c > > > index 99698ee1a744..f7068bd8b3d0 100644 > > > --- a/drivers/char/tpm/tpm_crb.c > > > +++ b/drivers/char/tpm/tpm_crb.c > > > @@ -771,12 +771,13 @@ static int crb_acpi_add(struct acpi_device *device) > > > FW_BUG "TPM2 ACPI table has wrong size %u for start method type %d\n", > > > buf->header.length, > > > ACPI_TPM2_COMMAND_BUFFER_WITH_PLUTON); > > > - return -EINVAL; > > > + rc = -EINVAL; > > > + goto out; > > > } > > > crb_pluton = ACPI_ADD_PTR(struct tpm2_crb_pluton, buf, sizeof(*buf)); > > > rc = crb_map_pluton(dev, priv, buf, crb_pluton); > > > if (rc) > > > - return rc; > > > + goto out; > > > } > > > > > > priv->sm = sm; > > > > Hi, > > > > polite reminder. > > > > While re-looking at it, the 3rd parameter of crb_map_pluton() (i.e. buf) > > looks unused and could be removed if it makes sense to you. > > This AFAIK went to Linux v6.2 already. Sorry I overlooked! There was bunch of patches with almost similar name, so I must have overlooked also back then. Now it is applied. Reviewed-by: Jarkko Sakkinen <jarkko@kernel.org> BR, Jarkko
diff --git a/drivers/char/tpm/tpm_crb.c b/drivers/char/tpm/tpm_crb.c index 99698ee1a744..f7068bd8b3d0 100644 --- a/drivers/char/tpm/tpm_crb.c +++ b/drivers/char/tpm/tpm_crb.c @@ -771,12 +771,13 @@ static int crb_acpi_add(struct acpi_device *device) FW_BUG "TPM2 ACPI table has wrong size %u for start method type %d\n", buf->header.length, ACPI_TPM2_COMMAND_BUFFER_WITH_PLUTON); - return -EINVAL; + rc = -EINVAL; + goto out; } crb_pluton = ACPI_ADD_PTR(struct tpm2_crb_pluton, buf, sizeof(*buf)); rc = crb_map_pluton(dev, priv, buf, crb_pluton); if (rc) - return rc; + goto out; } priv->sm = sm;
Some error paths don't call acpi_put_table() before returning. Branch to the correct place instead of doing some direct return. Fixes: 4d2732882703 ("tpm_crb: Add support for CRB devices based on Pluton") Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr> --- drivers/char/tpm/tpm_crb.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)