In case reading of PHY register fails in smsc95xx_bind(), the private data allocated earlier are not free()d. Free them before bailing out. Signed-off-by: Marek Vasut <marex@xxxxxxx> Cc: David S. Miller <davem@xxxxxxxxxxxxx> Cc: Nisar Sayed <Nisar.Sayed@xxxxxxxxxxxxx> Cc: Woojung Huh <Woojung.Huh@xxxxxxxxxxxxx> Cc: Andrew Lunn <andrew@xxxxxxx> Cc: Florian Fainelli <f.fainelli@xxxxxxxxx> Cc: linux-usb@xxxxxxxxxxxxxxx To: netdev@xxxxxxxxxxxxxxx --- drivers/net/usb/smsc95xx.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/net/usb/smsc95xx.c b/drivers/net/usb/smsc95xx.c index e3d08626828e..772429c17ae1 100644 --- a/drivers/net/usb/smsc95xx.c +++ b/drivers/net/usb/smsc95xx.c @@ -1303,7 +1303,7 @@ static int smsc95xx_bind(struct usbnet *dev, struct usb_interface *intf) /* detect device revision as different features may be available */ ret = smsc95xx_read_reg(dev, ID_REV, &val); if (ret < 0) - return ret; + goto err_read_reg; val >>= 16; pdata->chip_id = val; pdata->mdix_ctrl = get_mdix_status(dev->net); @@ -1329,6 +1329,9 @@ static int smsc95xx_bind(struct usbnet *dev, struct usb_interface *intf) schedule_delayed_work(&pdata->carrier_check, CARRIER_CHECK_DELAY); return 0; +err_read_reg: + kfree(pdata); + return ret; } static void smsc95xx_unbind(struct usbnet *dev, struct usb_interface *intf) -- 2.19.2