[net-next,2/8] smsc95xx: avoid memory leak in smsc95xx_bind

Message ID 8ecd274f439e642d1510780a4a5722fc72be64b4.camel@microchip.com
State New
Headers show
Series
  • Untitled series #40515
Related show

Commit Message

Andre.Edich@microchip.com June 29, 2020, 8:15 p.m.
In a case where the ID_REV register read is failed, the memory for a
private data structure has to be freed before returning error from the
function smsc95xx_unbind.

Signed-off-by: Andre Edich <andre.edich@microchip.com>

Signed-off-by: Parthiban Veerasooran <

Parthiban.Veerasooran@microchip.com>
---
 drivers/net/usb/smsc95xx.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

 	pdata->chip_id = val;
 	pdata->mdix_ctrl = get_mdix_status(dev->net);

Patch

diff --git a/drivers/net/usb/smsc95xx.c b/drivers/net/usb/smsc95xx.c
index eb404bb74e18..bb4ccbda031a 100644
--- a/drivers/net/usb/smsc95xx.c
+++ b/drivers/net/usb/smsc95xx.c
@@ -1293,7 +1293,8 @@  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 free_pdata;
+
 	val >>= 16;