2018-04-11 10:06:07

by Phil Elwell

[permalink] [raw]
Subject: [PATCH] lan78xx: Correctly indicate invalid OTP

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 <[email protected]>
---
drivers/net/usb/lan78xx.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/net/usb/lan78xx.c b/drivers/net/usb/lan78xx.c
index 55a78eb..32cf217 100644
--- a/drivers/net/usb/lan78xx.c
+++ b/drivers/net/usb/lan78xx.c
@@ -928,7 +928,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;
--
2.7.4



2018-04-11 13:03:57

by Andrew Lunn

[permalink] [raw]
Subject: Re: [PATCH] lan78xx: Correctly indicate invalid OTP

On Wed, Apr 11, 2018 at 10:59:17AM +0100, Phil Elwell wrote:
> 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.

Hi Phil

Do you know that the Fixes: tag should be for this? When did it break?

Thanks
Andrew

2018-04-11 13:07:02

by Phil Elwell

[permalink] [raw]
Subject: Re: [PATCH] lan78xx: Correctly indicate invalid OTP

Hi Andrew.

On 11/04/2018 13:57, Andrew Lunn wrote:
> On Wed, Apr 11, 2018 at 10:59:17AM +0100, Phil Elwell wrote:
>> 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.
>
> Hi Phil
>
> Do you know that the Fixes: tag should be for this? When did it break?

It's been broken since day 1, so:

Fixes: 55d7de9de6c3 ("Microchip's LAN7800 family USB 2/3 to 10/100/1000 Ethernet device driver")

2018-04-11 14:35:33

by David Miller

[permalink] [raw]
Subject: Re: [PATCH] lan78xx: Correctly indicate invalid OTP

From: Phil Elwell <[email protected]>
Date: Wed, 11 Apr 2018 10:59:17 +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 <[email protected]>

Applied with appropriate Fixes: tag added, and queud up for -stable.

Thanks.