diff mbox series

[2/2] asix: fix wrong return value in asix_check_host_enable()

Message ID 989915c5f8887e4a0281ed87325277aa8c997291.1640115493.git.paskripkin@gmail.com (mailing list archive)
State Superseded
Delegated to: Netdev Maintainers
Headers show
Series [1/2] asix: fix uninit-value in asix_mdio_read() | expand

Checks

Context Check Description
netdev/fixes_present success Fixes tag not required for -next series
netdev/subject_prefix warning Target tree name not specified in the subject
netdev/cover_letter success Single patches do not need cover letters
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/cc_maintainers success CCed 7 of 7 maintainers
netdev/build_clang success Errors and warnings before: 0 this patch: 0
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/verify_fixes success Fixes tag looks correct
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/checkpatch fail ERROR: spaces required around that ':' (ctx:VxW) ERROR: spaces required around that '?' (ctx:VxW)
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0
netdev/tree_selection success Guessing tree name failed - patch did not apply

Commit Message

Pavel Skripkin Dec. 21, 2021, 7:40 p.m. UTC
If asix_read_cmd() returns 0 on 30th interation, 0 will be returned from
asix_check_host_enable(), which is logically wrong. Fix it by returning
-ETIMEDOUT explicitly if we have exceeded 30 iterations

Fixes: a786e3195d6a ("net: asix: fix uninit value bugs")
Reported-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: Pavel Skripkin <paskripkin@gmail.com>
---
 drivers/net/usb/asix_common.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Andrew Lunn Dec. 21, 2021, 7:44 p.m. UTC | #1
On Tue, Dec 21, 2021 at 10:40:05PM +0300, Pavel Skripkin wrote:
> If asix_read_cmd() returns 0 on 30th interation, 0 will be returned from
> asix_check_host_enable(), which is logically wrong. Fix it by returning
> -ETIMEDOUT explicitly if we have exceeded 30 iterations
> 
> Fixes: a786e3195d6a ("net: asix: fix uninit value bugs")
> Reported-by: Andrew Lunn <andrew@lunn.ch>
> Signed-off-by: Pavel Skripkin <paskripkin@gmail.com>
> ---
>  drivers/net/usb/asix_common.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/net/usb/asix_common.c b/drivers/net/usb/asix_common.c
> index 06823d7141b6..8c61d410a123 100644
> --- a/drivers/net/usb/asix_common.c
> +++ b/drivers/net/usb/asix_common.c
> @@ -83,7 +83,7 @@ static int asix_check_host_enable(struct usbnet *dev, int in_pm)
>  			break;
>  	}
>  
> -	return ret;
> +	return i >= 30? -ETIMEDOUT: ret;

I think the coding style guidelines would recommend a space before the ?

I would also replace the 30 with a #define, both here and in the for
loop.

	Andrew
Pavel Skripkin Dec. 21, 2021, 8 p.m. UTC | #2
On 12/21/21 22:44, Andrew Lunn wrote:
> On Tue, Dec 21, 2021 at 10:40:05PM +0300, Pavel Skripkin wrote:
>> If asix_read_cmd() returns 0 on 30th interation, 0 will be returned from
>> asix_check_host_enable(), which is logically wrong. Fix it by returning
>> -ETIMEDOUT explicitly if we have exceeded 30 iterations
>> 
>> Fixes: a786e3195d6a ("net: asix: fix uninit value bugs")
>> Reported-by: Andrew Lunn <andrew@lunn.ch>
>> Signed-off-by: Pavel Skripkin <paskripkin@gmail.com>
>> ---
>>  drivers/net/usb/asix_common.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>> 
>> diff --git a/drivers/net/usb/asix_common.c b/drivers/net/usb/asix_common.c
>> index 06823d7141b6..8c61d410a123 100644
>> --- a/drivers/net/usb/asix_common.c
>> +++ b/drivers/net/usb/asix_common.c
>> @@ -83,7 +83,7 @@ static int asix_check_host_enable(struct usbnet *dev, int in_pm)
>>  			break;
>>  	}
>>  
>> -	return ret;
>> +	return i >= 30? -ETIMEDOUT: ret;
> 
> I think the coding style guidelines would recommend a space before the ?
> 

Ah, yes, I forgot to run chechpatch on 2nd one, sorry. Will fix in v2

> I would also replace the 30 with a #define, both here and in the for
> loop.

Will fix in v2 as well. Thanks for review!



With regards,
Pavel Skripkin
diff mbox series

Patch

diff --git a/drivers/net/usb/asix_common.c b/drivers/net/usb/asix_common.c
index 06823d7141b6..8c61d410a123 100644
--- a/drivers/net/usb/asix_common.c
+++ b/drivers/net/usb/asix_common.c
@@ -83,7 +83,7 @@  static int asix_check_host_enable(struct usbnet *dev, int in_pm)
 			break;
 	}
 
-	return ret;
+	return i >= 30? -ETIMEDOUT: ret;
 }
 
 static void reset_asix_rx_fixup_info(struct asix_rx_fixup_info *rx)