public inbox for stable@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] crypto: atmel-sha204a - Fix uninitialized data access on OTP read error
@ 2026-02-20 13:31 Thorsten Blum
  2026-02-22 17:29 ` Lothar Rubusch
  2026-03-07  5:27 ` Herbert Xu
  0 siblings, 2 replies; 4+ messages in thread
From: Thorsten Blum @ 2026-02-20 13:31 UTC (permalink / raw)
  To: Herbert Xu, David S. Miller, Nicolas Ferre, Alexandre Belloni,
	Claudiu Beznea, Lothar Rubusch
  Cc: Thorsten Blum, stable, linux-crypto, linux-arm-kernel,
	linux-kernel

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


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

* Re: [PATCH] crypto: atmel-sha204a - Fix uninitialized data access on OTP read error
  2026-02-20 13:31 [PATCH] crypto: atmel-sha204a - Fix uninitialized data access on OTP read error Thorsten Blum
@ 2026-02-22 17:29 ` Lothar Rubusch
  2026-02-22 18:23   ` Thorsten Blum
  2026-03-07  5:27 ` Herbert Xu
  1 sibling, 1 reply; 4+ messages in thread
From: Lothar Rubusch @ 2026-02-22 17:29 UTC (permalink / raw)
  To: Thorsten Blum
  Cc: Herbert Xu, David S. Miller, Nicolas Ferre, Alexandre Belloni,
	Claudiu Beznea, stable, linux-crypto, linux-arm-kernel,
	linux-kernel

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
>

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

* Re: [PATCH] crypto: atmel-sha204a - Fix uninitialized data access on OTP read error
  2026-02-22 17:29 ` Lothar Rubusch
@ 2026-02-22 18:23   ` Thorsten Blum
  0 siblings, 0 replies; 4+ messages in thread
From: Thorsten Blum @ 2026-02-22 18:23 UTC (permalink / raw)
  To: Lothar Rubusch
  Cc: Herbert Xu, David S. Miller, Nicolas Ferre, Alexandre Belloni,
	Claudiu Beznea, stable, linux-crypto, linux-arm-kernel,
	linux-kernel

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/


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

* Re: [PATCH] crypto: atmel-sha204a - Fix uninitialized data access on OTP read error
  2026-02-20 13:31 [PATCH] crypto: atmel-sha204a - Fix uninitialized data access on OTP read error Thorsten Blum
  2026-02-22 17:29 ` Lothar Rubusch
@ 2026-03-07  5:27 ` Herbert Xu
  1 sibling, 0 replies; 4+ messages in thread
From: Herbert Xu @ 2026-03-07  5:27 UTC (permalink / raw)
  To: Thorsten Blum
  Cc: David S. Miller, Nicolas Ferre, Alexandre Belloni, Claudiu Beznea,
	Lothar Rubusch, stable, linux-crypto, linux-arm-kernel,
	linux-kernel

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

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

end of thread, other threads:[~2026-03-07  5:27 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-02-20 13:31 [PATCH] crypto: atmel-sha204a - Fix uninitialized data access on OTP read error Thorsten Blum
2026-02-22 17:29 ` Lothar Rubusch
2026-02-22 18:23   ` Thorsten Blum
2026-03-07  5:27 ` Herbert Xu

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