drivers/crypto/atmel-sha204a.c | 4 ++++ 1 file changed, 4 insertions(+)
Return early if atmel_i2c_send_receive() fails to avoid checking
potentially uninitialized data in 'cmd.data'.
Cc: stable@vger.kernel.org
Fixes: e05ce444e9e5 ("crypto: atmel-sha204a - add reading from otp zone")
Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
---
drivers/crypto/atmel-sha204a.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/drivers/crypto/atmel-sha204a.c b/drivers/crypto/atmel-sha204a.c
index 0fcf4a39de27..f4a04b297257 100644
--- a/drivers/crypto/atmel-sha204a.c
+++ b/drivers/crypto/atmel-sha204a.c
@@ -103,6 +103,10 @@ static int atmel_sha204a_otp_read(struct i2c_client *client, u16 addr, u8 *otp)
}
ret = atmel_i2c_send_receive(client, &cmd);
+ if (ret < 0) {
+ dev_err(&client->dev, "failed to read otp at %04X\n", addr);
+ return ret;
+ }
if (cmd.data[0] == 0xff) {
dev_err(&client->dev, "failed, device not ready\n");
--
Thorsten Blum <thorsten.blum@linux.dev>
GPG: 1D60 735E 8AEF 3BE4 73B6 9D84 7336 78FD 8DFE EAD4
On Fri, Feb 20, 2026 at 02:31:36PM +0100, Thorsten Blum wrote:
> Return early if atmel_i2c_send_receive() fails to avoid checking
> potentially uninitialized data in 'cmd.data'.
>
> Cc: stable@vger.kernel.org
> Fixes: e05ce444e9e5 ("crypto: atmel-sha204a - add reading from otp zone")
> Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
> ---
> drivers/crypto/atmel-sha204a.c | 4 ++++
> 1 file changed, 4 insertions(+)
Patch applied. Thanks.
--
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
Hi Thorsten! So this one was tested on your hardware?
Wouldn't it make more sense to squash this with the patch before: 'Fix
error codes in OTP reads' (which IMHO actually fixes mainly the bounds
check)? This on it's own I'd consider rather a refac than "Fixes".
On Fri, Feb 20, 2026 at 2:32 PM Thorsten Blum <thorsten.blum@linux.dev> wrote:
>
> Return early if atmel_i2c_send_receive() fails to avoid checking
> potentially uninitialized data in 'cmd.data'.
>
> Cc: stable@vger.kernel.org
> Fixes: e05ce444e9e5 ("crypto: atmel-sha204a - add reading from otp zone")
> Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
> ---
> drivers/crypto/atmel-sha204a.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/drivers/crypto/atmel-sha204a.c b/drivers/crypto/atmel-sha204a.c
> index 0fcf4a39de27..f4a04b297257 100644
> --- a/drivers/crypto/atmel-sha204a.c
> +++ b/drivers/crypto/atmel-sha204a.c
> @@ -103,6 +103,10 @@ static int atmel_sha204a_otp_read(struct i2c_client *client, u16 addr, u8 *otp)
> }
>
> ret = atmel_i2c_send_receive(client, &cmd);
> + if (ret < 0) {
> + dev_err(&client->dev, "failed to read otp at %04X\n", addr);
> + return ret;
> + }
>
> if (cmd.data[0] == 0xff) {
> dev_err(&client->dev, "failed, device not ready\n");
> --
> Thorsten Blum <thorsten.blum@linux.dev>
> GPG: 1D60 735E 8AEF 3BE4 73B6 9D84 7336 78FD 8DFE EAD4
>
On 22. Feb 2026, at 18:29, Lothar Rubusch wrote: > Hi Thorsten! So this one was tested on your hardware? > > Wouldn't it make more sense to squash this with the patch before: 'Fix > error codes in OTP reads' (which IMHO actually fixes mainly the bounds > check)? This on it's own I'd consider rather a refac than "Fixes". Sorry, I forgot to add that I only compile-tested it (like the others), as I don't have access to the hardware right now. If you could test it on your setup, that would be very much appreciated. And yes, happy to squash them, I just found it after submitting [1]. Thanks, Thorsten [1] https://lore.kernel.org/lkml/20260215205152.518472-3-thorsten.blum@linux.dev/
© 2016 - 2026 Red Hat, Inc.