lan78xx: Correctly indicate invalid OTP
authorPhil Elwell <phil@raspberrypi.org>
Tue, 28 Nov 2017 12:02:37 +0000 (12:02 +0000)
committerRaspbian kernel package updater <root@raspbian.org>
Sat, 31 Mar 2018 14:57:25 +0000 (15:57 +0100)
lan78xx_read_otp tries to return -EINVAL in the event of invalid OTP
content, but the value gets overwritten before it is returned and the
read goes ahead anyway. Make the read conditional as it should be
and preserve the error code.

Signed-off-by: Phil Elwell <phil@raspberrypi.org>
drivers/net/usb/lan78xx.c

index aac8f206908797bfdd781ae9b14ba8f03afcb75a..0798b260c38d2ce12ac73dac2ee5a16498c9fc1c 100644 (file)
@@ -874,7 +874,8 @@ static int lan78xx_read_otp(struct lan78xx_net *dev, u32 offset,
                        offset += 0x100;
                else
                        ret = -EINVAL;
-               ret = lan78xx_read_raw_otp(dev, offset, length, data);
+               if (!ret)
+                       ret = lan78xx_read_raw_otp(dev, offset, length, data);
        }
 
        return ret;