2023-10-19 08:41:02

by Su Hui

[permalink] [raw]
Subject: [PATCH] net: lan78xx: add an error code check in lan78xx_write_raw_eeprom

check the value of 'ret' after call 'lan78xx_read_reg'.

Signed-off-by: Su Hui <[email protected]>
---

Clang complains that value stored to 'ret' is never read.
Maybe this place miss an error code check, I'm not sure
about this.

drivers/net/usb/lan78xx.c | 4 ++++
1 file changed, 4 insertions(+)

diff --git a/drivers/net/usb/lan78xx.c b/drivers/net/usb/lan78xx.c
index 59cde06aa7f6..347788336b11 100644
--- a/drivers/net/usb/lan78xx.c
+++ b/drivers/net/usb/lan78xx.c
@@ -977,6 +977,10 @@ static int lan78xx_write_raw_eeprom(struct lan78xx_net *dev, u32 offset,
* disable & restore LED function to access EEPROM.
*/
ret = lan78xx_read_reg(dev, HW_CFG, &val);
+ if (ret < 0) {
+ retval = -EIO;
+ goto exit;
+ }
saved = val;
if (dev->chipid == ID_REV_CHIP_ID_7800_) {
val &= ~(HW_CFG_LED1_EN_ | HW_CFG_LED0_EN_);
--
2.30.2


2023-10-19 10:35:58

by Dan Carpenter

[permalink] [raw]
Subject: Re: [PATCH] net: lan78xx: add an error code check in lan78xx_write_raw_eeprom

On Thu, Oct 19, 2023 at 04:40:23PM +0800, Su Hui wrote:
> check the value of 'ret' after call 'lan78xx_read_reg'.
>
> Signed-off-by: Su Hui <[email protected]>
> ---
>
> Clang complains that value stored to 'ret' is never read.
> Maybe this place miss an error code check, I'm not sure
> about this.

There are a bunch more "ret = " assignments which aren't used in this
function.

regards,
dan carpenter

2023-10-20 02:59:58

by Su Hui

[permalink] [raw]
Subject: Re: [PATCH] net: lan78xx: add an error code check in lan78xx_write_raw_eeprom

On 2023/10/19 18:34, Dan Carpenter wrote:
> On Thu, Oct 19, 2023 at 04:40:23PM +0800, Su Hui wrote:
>> check the value of 'ret' after call 'lan78xx_read_reg'.
>>
>> Signed-off-by: Su Hui <[email protected]>
>> ---
>>
>> Clang complains that value stored to 'ret' is never read.
>> Maybe this place miss an error code check, I'm not sure
>> about this.
> There are a bunch more "ret = " assignments which aren't used in this
> function.
Yep, same problemĀ  exists at lan78xx_read_raw_eeprom().
I try to send v2 patch to fix this.

Su Hui