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:
Thorsten Blum
2026-07-28 22:58:26 +02:00
committed by Herbert Xu
parent 006fb75aa3
commit bda65642eb

View File

@@ -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;