* [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
* [PATCH 2/2] crypto: atmel-ecc - drop redundant return variable
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 ` Thorsten Blum
0 siblings, 0 replies; 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
In atmel_ecdh_generate_public_key(), drop the redundant return variable
and return -EINVAL and 0 directly.
Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
---
drivers/crypto/atmel-ecc.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/drivers/crypto/atmel-ecc.c b/drivers/crypto/atmel-ecc.c
index f98782f0a2c6..0c6ab5da9299 100644
--- a/drivers/crypto/atmel-ecc.c
+++ b/drivers/crypto/atmel-ecc.c
@@ -125,7 +125,6 @@ static int atmel_ecdh_generate_public_key(struct kpp_request *req)
struct crypto_kpp *tfm = crypto_kpp_reqtfm(req);
struct atmel_ecdh_ctx *ctx = kpp_tfm_ctx(tfm);
size_t copied, nbytes;
- int ret = 0;
if (ctx->do_fallback) {
kpp_request_set_tfm(req, ctx->fallback);
@@ -143,9 +142,9 @@ static int atmel_ecdh_generate_public_key(struct kpp_request *req)
sg_nents_for_len(req->dst, nbytes),
ctx->public_key, nbytes);
if (copied != nbytes)
- ret = -EINVAL;
+ return -EINVAL;
- return ret;
+ return 0;
}
static int atmel_ecdh_compute_shared_secret(struct kpp_request *req)
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-07-28 20:59 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