mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-08-31 08:15:07 -04:00
crypto: atmel-ecc - simplify control flow in atmel_ecdh_set_secret
Free the public key directly on I2C transaction failure and remove the free_public_key label to simplify the code. Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
This commit is contained in:
committed by
Herbert Xu
parent
006fb75aa3
commit
bda65642eb
@@ -106,17 +106,14 @@ static int atmel_ecdh_set_secret(struct crypto_kpp *tfm, const void *buf,
|
||||
atmel_i2c_init_genkey_cmd(cmd, DATA_SLOT_2);
|
||||
|
||||
ret = atmel_i2c_send_receive(ctx->client, cmd);
|
||||
if (ret)
|
||||
goto free_public_key;
|
||||
if (ret) {
|
||||
kfree(public_key);
|
||||
goto free_cmd;
|
||||
}
|
||||
|
||||
memcpy(public_key, &cmd->data[RSP_DATA_IDX], ATMEL_ECC_PUBKEY_SIZE);
|
||||
ctx->public_key = public_key;
|
||||
|
||||
kfree(cmd);
|
||||
return 0;
|
||||
|
||||
free_public_key:
|
||||
kfree(public_key);
|
||||
free_cmd:
|
||||
kfree(cmd);
|
||||
return ret;
|
||||
|
||||
Reference in New Issue
Block a user