diff options
author | Wenwen Wang <wenwen@cs.uga.edu> | 2019-08-14 13:56:43 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2019-09-10 10:32:16 +0100 |
commit | 849922a81e5c74c6006aec4f74eee6dac764c311 (patch) | |
tree | 7b7d70298762e1c782450f875c46ec32e9147fed | |
parent | f51ddf376750556869e01aa3efacd356948b5f28 (diff) | |
download | linux-stable-849922a81e5c74c6006aec4f74eee6dac764c311.tar.gz linux-stable-849922a81e5c74c6006aec4f74eee6dac764c311.tar.bz2 linux-stable-849922a81e5c74c6006aec4f74eee6dac764c311.zip |
net: kalmia: fix memory leaks
[ Upstream commit f1472cb09f11ddb41d4be84f0650835cb65a9073 ]
In kalmia_init_and_get_ethernet_addr(), 'usb_buf' is allocated through
kmalloc(). In the following execution, if the 'status' returned by
kalmia_send_init_packet() is not 0, 'usb_buf' is not deallocated, leading
to memory leaks. To fix this issue, add the 'out' label to free 'usb_buf'.
Signed-off-by: Wenwen Wang <wenwen@cs.uga.edu>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
-rw-r--r-- | drivers/net/usb/kalmia.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/drivers/net/usb/kalmia.c b/drivers/net/usb/kalmia.c index ce0b0b4e3a57..c677ec2bae18 100644 --- a/drivers/net/usb/kalmia.c +++ b/drivers/net/usb/kalmia.c @@ -117,16 +117,16 @@ kalmia_init_and_get_ethernet_addr(struct usbnet *dev, u8 *ethernet_addr) status = kalmia_send_init_packet(dev, usb_buf, sizeof(init_msg_1) / sizeof(init_msg_1[0]), usb_buf, 24); if (status != 0) - return status; + goto out; memcpy(usb_buf, init_msg_2, 12); status = kalmia_send_init_packet(dev, usb_buf, sizeof(init_msg_2) / sizeof(init_msg_2[0]), usb_buf, 28); if (status != 0) - return status; + goto out; memcpy(ethernet_addr, usb_buf + 10, ETH_ALEN); - +out: kfree(usb_buf); return status; } |