aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorMing Lei <ming.lei@canonical.com>2012-11-05 23:53:06 -0500
committerDavid S. Miller <davem@davemloft.net>2012-11-07 03:53:38 -0500
commit06a221be022c2cc98a48e0808a4ef0dc8f0b3a34 (patch)
tree935fe2fc77739a73ddc5d7c17480c55c628da98d /drivers
parent47bbea4171025c96e80f7ded7595697a2cb56552 (diff)
usbnet: smsc95xx: fix memory leak in smsc95xx_suspend
This patch fixes memory leak in smsc95xx_suspend. Also, it isn't necessary to bother mm to allocate 8bytes/16byte, and we can use stack variable safely. Acked-By: Steve Glendinning <steve.glendinning@shawell.net> Signed-off-by: Ming Lei <ming.lei@canonical.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/net/usb/smsc95xx.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/drivers/net/usb/smsc95xx.c b/drivers/net/usb/smsc95xx.c
index 46cd784467d5..05ead8a3335c 100644
--- a/drivers/net/usb/smsc95xx.c
+++ b/drivers/net/usb/smsc95xx.c
@@ -1070,11 +1070,15 @@ static int smsc95xx_suspend(struct usb_interface *intf, pm_message_t message)
1070 1070
1071 if (pdata->wolopts & (WAKE_BCAST | WAKE_MCAST | WAKE_ARP | WAKE_UCAST)) { 1071 if (pdata->wolopts & (WAKE_BCAST | WAKE_MCAST | WAKE_ARP | WAKE_UCAST)) {
1072 u32 *filter_mask = kzalloc(32, GFP_KERNEL); 1072 u32 *filter_mask = kzalloc(32, GFP_KERNEL);
1073 u32 *command = kzalloc(2, GFP_KERNEL); 1073 u32 command[2];
1074 u32 *offset = kzalloc(2, GFP_KERNEL); 1074 u32 offset[2];
1075 u32 *crc = kzalloc(4, GFP_KERNEL); 1075 u32 crc[4];
1076 int i, filter = 0; 1076 int i, filter = 0;
1077 1077
1078 memset(command, 0, sizeof(command));
1079 memset(offset, 0, sizeof(offset));
1080 memset(crc, 0, sizeof(crc));
1081
1078 if (pdata->wolopts & WAKE_BCAST) { 1082 if (pdata->wolopts & WAKE_BCAST) {
1079 const u8 bcast[] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}; 1083 const u8 bcast[] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
1080 netdev_info(dev->net, "enabling broadcast detection"); 1084 netdev_info(dev->net, "enabling broadcast detection");
@@ -1128,8 +1132,11 @@ static int smsc95xx_suspend(struct usb_interface *intf, pm_message_t message)
1128 1132
1129 for (i = 0; i < (pdata->wuff_filter_count * 4); i++) { 1133 for (i = 0; i < (pdata->wuff_filter_count * 4); i++) {
1130 ret = smsc95xx_write_reg(dev, WUFF, filter_mask[i]); 1134 ret = smsc95xx_write_reg(dev, WUFF, filter_mask[i]);
1135 if (ret < 0)
1136 kfree(filter_mask);
1131 check_warn_return(ret, "Error writing WUFF"); 1137 check_warn_return(ret, "Error writing WUFF");
1132 } 1138 }
1139 kfree(filter_mask);
1133 1140
1134 for (i = 0; i < (pdata->wuff_filter_count / 4); i++) { 1141 for (i = 0; i < (pdata->wuff_filter_count / 4); i++) {
1135 ret = smsc95xx_write_reg(dev, WUFF, command[i]); 1142 ret = smsc95xx_write_reg(dev, WUFF, command[i]);