crypto: atmel-sha204a - Fix uninitialized data access on OTP read error
PATCH 1/1 crypto: atmel-sha204a - Fix uninitialized data access on OTP read error
Return early if atmel_i2c_send_receive() fails to avoid checking potentially uninitialized data in 'cmd.data'.
--- drivers/crypto/atmel-sha204a.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/crypto/atmel-sha204a.c +4 -0
@@ -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" );
Signature · 2 lines
Thorsten Blum <[email protected]> GPG: 1D60 735E 8AEF 3BE4 73B6 9D84 7336 78FD 8DFE EAD4
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".
Quoted 30 lines · Thorsten Blum
Return early if
atmel_i2c_send_receive()fails to avoid checking potentially uninitialized data in 'cmd.data'.Fixes e05ce444e9e5 ("crypto: atmel-sha204a - add reading from otp zone")Signed-off-by Thorsten Blum <[email protected]>--- drivers/crypto/atmel-sha204a.c | 4 ++++ 1 file changed, 4 insertions(+)drivers/crypto/atmel-sha204a.c +4
-1@@ -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 <[email protected]>
GPG: 1D60 735E 8AEF 3BE4 73B6 9D84 7336 78FD 8DFE EAD4
Quoted 5 lines · Lothar Rubusch
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
Herbert Xu
maintainerQuoted 9 lines · Thorsten Blum
Return early if
atmel_i2c_send_receive()fails to avoid checking potentially uninitialized data in 'cmd.data'.Fixes e05ce444e9e5 ("crypto: atmel-sha204a - add reading from otp zone")Signed-off-by Thorsten Blum <[email protected]>--- drivers/crypto/atmel-sha204a.c | 4 ++++ 1 file changed, 4 insertions(+)
Patch applied. Thanks.
Signature · 3 lines
Email: Herbert Xu <[email protected]> Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt