Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

net: usb: lan78xx: fix use of improperly initialized dev->chipid in lan78xx_reset

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: a0db7d10b76e ("lan78xx: Add to handle mux control per chip id")
Signed-off-by: I Viswanath <viswanathiyyappan@gmail.com>
Reviewed-by: Vadim Fedorenko <vadim.fedorenko@linux.dev>
Reviewed-by: Khalid Aziz <khalid@kernel.org>
Link: https://patch.msgid.link/20251013181648.35153-1-viswanathiyyappan@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

I Viswanath and committed by
Jakub Kicinski
8d93ff40 5e655aad

+4 -4
+4 -4
drivers/net/usb/lan78xx.c
··· 3250 3250 } 3251 3251 } while (buf & HW_CFG_LRST_); 3252 3252 3253 - ret = lan78xx_init_mac_address(dev); 3254 - if (ret < 0) 3255 - return ret; 3256 - 3257 3253 /* save DEVID for later usage */ 3258 3254 ret = lan78xx_read_reg(dev, ID_REV, &buf); 3259 3255 if (ret < 0) ··· 3257 3261 3258 3262 dev->chipid = (buf & ID_REV_CHIP_ID_MASK_) >> 16; 3259 3263 dev->chiprev = buf & ID_REV_CHIP_REV_MASK_; 3264 + 3265 + ret = lan78xx_init_mac_address(dev); 3266 + if (ret < 0) 3267 + return ret; 3260 3268 3261 3269 /* Respond to the IN token with a NAK */ 3262 3270 ret = lan78xx_read_reg(dev, USB_CFG0, &buf);