Skip to content

Commit d658d59

Browse files
committed
tpm: Return tpm2_sessions_init() when null key creation fails
Do not continue tpm2_sessions_init() further if the null key pair creation fails. Cc: [email protected] # v6.10+ Fixes: d2add27 ("tpm: Add NULL primary creation") Reviewed-by: Stefan Berger <[email protected]> Signed-off-by: Jarkko Sakkinen <[email protected]>
1 parent 8198375 commit d658d59

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

drivers/char/tpm/tpm2-sessions.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1347,14 +1347,21 @@ static int tpm2_create_null_primary(struct tpm_chip *chip)
13471347
*
13481348
* Derive and context save the null primary and allocate memory in the
13491349
* struct tpm_chip for the authorizations.
1350+
*
1351+
* Return:
1352+
* * 0 - OK
1353+
* * -errno - A system error
1354+
* * TPM_RC - A TPM error
13501355
*/
13511356
int tpm2_sessions_init(struct tpm_chip *chip)
13521357
{
13531358
int rc;
13541359

13551360
rc = tpm2_create_null_primary(chip);
1356-
if (rc)
1357-
dev_err(&chip->dev, "TPM: security failed (NULL seed derivation): %d\n", rc);
1361+
if (rc) {
1362+
dev_err(&chip->dev, "null key creation failed with %d\n", rc);
1363+
return rc;
1364+
}
13581365

13591366
chip->auth = kmalloc(sizeof(*chip->auth), GFP_KERNEL);
13601367
if (!chip->auth)

0 commit comments

Comments
 (0)