Skip to content

Commit d1652b7

Browse files
pskrgagkuba-moo
authored andcommitted
asix: fix wrong return value in asix_check_host_enable()
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 Also, replaced 30 with #define as suggested by Andrew Fixes: a786e31 ("net: asix: fix uninit value bugs") Reported-by: Andrew Lunn <[email protected]> Signed-off-by: Pavel Skripkin <[email protected]> Reviewed-by: Andrew Lunn <[email protected]> Link: https://lore.kernel.org/r/ecd3470ce6c2d5697ac635d0d3b14a47defb4acb.1640117288.git.paskripkin@gmail.com Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 8035b1a commit d1652b7

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

drivers/net/usb/asix_common.c

+4-2
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99

1010
#include "asix.h"
1111

12+
#define AX_HOST_EN_RETRIES 30
13+
1214
int asix_read_cmd(struct usbnet *dev, u8 cmd, u16 value, u16 index,
1315
u16 size, void *data, int in_pm)
1416
{
@@ -68,7 +70,7 @@ static int asix_check_host_enable(struct usbnet *dev, int in_pm)
6870
int i, ret;
6971
u8 smsr;
7072

71-
for (i = 0; i < 30; ++i) {
73+
for (i = 0; i < AX_HOST_EN_RETRIES; ++i) {
7274
ret = asix_set_sw_mii(dev, in_pm);
7375
if (ret == -ENODEV || ret == -ETIMEDOUT)
7476
break;
@@ -83,7 +85,7 @@ static int asix_check_host_enable(struct usbnet *dev, int in_pm)
8385
break;
8486
}
8587

86-
return ret;
88+
return i >= AX_HOST_EN_RETRIES ? -ETIMEDOUT : ret;
8789
}
8890

8991
static void reset_asix_rx_fixup_info(struct asix_rx_fixup_info *rx)

0 commit comments

Comments
 (0)