Skip to content

Commit d8a3a53

Browse files
CraftyChimeragregkh
authored andcommitted
net: usb: lan78xx: fix use of improperly initialized dev->chipid in lan78xx_reset
[ Upstream commit 8d93ff4 ] dev->chipid is used in lan78xx_init_mac_address before it's initialized: lan78xx_reset() { lan78xx_init_mac_address() lan78xx_read_eeprom() lan78xx_read_raw_eeprom() <- dev->chipid is used here dev->chipid = ... <- dev->chipid is initialized correctly here } Reorder initialization so that dev->chipid is set before calling lan78xx_init_mac_address(). Fixes: a0db7d1 ("lan78xx: Add to handle mux control per chip id") Signed-off-by: I Viswanath <[email protected]> Reviewed-by: Vadim Fedorenko <[email protected]> Reviewed-by: Khalid Aziz <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]> Signed-off-by: Sasha Levin <[email protected]>
1 parent f30f006 commit d8a3a53

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

drivers/net/usb/lan78xx.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2923,10 +2923,6 @@ static int lan78xx_reset(struct lan78xx_net *dev)
29232923
}
29242924
} while (buf & HW_CFG_LRST_);
29252925

2926-
ret = lan78xx_init_mac_address(dev);
2927-
if (ret < 0)
2928-
return ret;
2929-
29302926
/* save DEVID for later usage */
29312927
ret = lan78xx_read_reg(dev, ID_REV, &buf);
29322928
if (ret < 0)
@@ -2935,6 +2931,10 @@ static int lan78xx_reset(struct lan78xx_net *dev)
29352931
dev->chipid = (buf & ID_REV_CHIP_ID_MASK_) >> 16;
29362932
dev->chiprev = buf & ID_REV_CHIP_REV_MASK_;
29372933

2934+
ret = lan78xx_init_mac_address(dev);
2935+
if (ret < 0)
2936+
return ret;
2937+
29382938
/* Respond to the IN token with a NAK */
29392939
ret = lan78xx_read_reg(dev, USB_CFG0, &buf);
29402940
if (ret < 0)

0 commit comments

Comments
 (0)