Linux cryptographic layer development
 help / color / mirror / Atom feed
* [PATCH 1/2] crypto: atmel-ecc - simplify control flow in atmel_ecdh_set_secret
@ 2026-07-28 20:58 Thorsten Blum
  2026-07-28 20:58 ` [PATCH 2/2] crypto: atmel-ecc - drop redundant return variable Thorsten Blum
  0 siblings, 1 reply; 2+ messages in thread
From: Thorsten Blum @ 2026-07-28 20:58 UTC (permalink / raw)
  To: Thorsten Blum, Herbert Xu, David S. Miller, Nicolas Ferre,
	Alexandre Belloni, Claudiu Beznea
  Cc: linux-crypto, linux-arm-kernel, linux-kernel

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>
---
 drivers/crypto/atmel-ecc.c | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/drivers/crypto/atmel-ecc.c b/drivers/crypto/atmel-ecc.c
index 21192a042fa2..f98782f0a2c6 100644
--- a/drivers/crypto/atmel-ecc.c
+++ b/drivers/crypto/atmel-ecc.c
@@ -107,17 +107,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;

^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-07-28 20:58 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-28 20:58 [PATCH 1/2] crypto: atmel-ecc - simplify control flow in atmel_ecdh_set_secret Thorsten Blum
2026-07-28 20:58 ` [PATCH 2/2] crypto: atmel-ecc - drop redundant return variable Thorsten Blum

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox