From: Andre Edich <andre.edich@microchip.com>
To: <netdev@vger.kernel.org>, <UNGLinuxDriver@microchip.com>,
<steve.glendinning@shawell.net>
Cc: <Parthiban.Veerasooran@microchip.com>,
Andre Edich <andre.edich@microchip.com>
Subject: [PATCH net v2 2/2] smsc95xx: avoid memory leak in smsc95xx_bind
Date: Mon, 6 Jul 2020 10:39:35 +0200 [thread overview]
Message-ID: <20200706083935.19040-3-andre.edich@microchip.com> (raw)
In-Reply-To: <20200706083935.19040-1-andre.edich@microchip.com>
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_bind.
Fixes: bbd9f9ee69242 ("smsc95xx: add wol support for more frame types")
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(-)
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;
pdata->chip_id = val;
pdata->mdix_ctrl = get_mdix_status(dev->net);
--
2.27.0
next prev parent reply other threads:[~2020-07-06 8:40 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-06 8:39 [PATCH net v2 0/2] smsc95xx: fix smsc95xx_bind Andre Edich
2020-07-06 8:39 ` [PATCH net v2 1/2] smsc95xx: check return value of smsc95xx_reset Andre Edich
2020-07-06 8:39 ` Andre Edich [this message]
2020-07-06 19:22 ` [PATCH net v2 0/2] smsc95xx: fix smsc95xx_bind David Miller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200706083935.19040-3-andre.edich@microchip.com \
--to=andre.edich@microchip.com \
--cc=Parthiban.Veerasooran@microchip.com \
--cc=UNGLinuxDriver@microchip.com \
--cc=netdev@vger.kernel.org \
--cc=steve.glendinning@shawell.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.