diff options
author | Hayes Wang <hayeswang@realtek.com> | 2020-12-16 12:03:22 +0300 |
---|---|---|
committer | Marek Vasut <marex@denx.de> | 2020-12-16 12:27:09 +0300 |
commit | 17d5a461a0da967c511032a160278b0e1d9fd349 (patch) | |
tree | 356ad791cd1970874ec7a740b9d49372c2289d64 /drivers/usb | |
parent | 621ed49d3a2ea3c45be1cf774bef48439bd566f3 (diff) | |
download | u-boot-17d5a461a0da967c511032a160278b0e1d9fd349.tar.xz |
eth/r8152: free previous memory if r8152_eth_probe fail
The r8152_eth_probe() may allocate a memory for ss->dev_priv.
It has to be freed if r8152_eth_probe() fails finally.
Signed-off-by: Hayes Wang <hayeswang@realtek.com>
Diffstat (limited to 'drivers/usb')
-rw-r--r-- | drivers/usb/eth/r8152.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/drivers/usb/eth/r8152.c b/drivers/usb/eth/r8152.c index 215bcbbef8..82a05a9c35 100644 --- a/drivers/usb/eth/r8152.c +++ b/drivers/usb/eth/r8152.c @@ -1647,7 +1647,7 @@ int r8152_eth_probe(struct usb_device *dev, unsigned int ifnum, if (usb_set_interface(dev, iface_desc->bInterfaceNumber, 0) || !ss->ep_in || !ss->ep_out || !ss->ep_int) { debug("Problems with device\n"); - return 0; + goto error; } dev->privptr = (void *)ss; @@ -1659,7 +1659,7 @@ int r8152_eth_probe(struct usb_device *dev, unsigned int ifnum, r8152b_get_version(tp); if (rtl_ops_init(tp)) - return 0; + goto error; tp->rtl_ops.init(tp); tp->rtl_ops.up(tp); @@ -1669,6 +1669,11 @@ int r8152_eth_probe(struct usb_device *dev, unsigned int ifnum, DUPLEX_FULL); return 1; + +error: + cfree(ss->dev_priv); + ss->dev_priv = 0; + return 0; } int r8152_eth_get_info(struct usb_device *dev, struct ueth_data *ss, |