diff options
author | Hauke Mehrtens <hauke@hauke-m.de> | 2012-01-28 13:52:37 +0000 |
---|---|---|
committer | Hauke Mehrtens <hauke@hauke-m.de> | 2012-01-28 13:52:37 +0000 |
commit | b9da4dcb6b755568d7728d9e90feaad686b0b8c0 (patch) | |
tree | dc557d368fd2d0f42545800954e8c0604cb54123 /package/switch/src/switch-core.c | |
parent | eeb00634a7715204481a5fd83664a697e414bbfd (diff) | |
download | mtk-20170518-b9da4dcb6b755568d7728d9e90feaad686b0b8c0.zip mtk-20170518-b9da4dcb6b755568d7728d9e90feaad686b0b8c0.tar.gz mtk-20170518-b9da4dcb6b755568d7728d9e90feaad686b0b8c0.tar.bz2 |
switch: fix some memory leaks in switch_parse_vlan()
SVN-Revision: 29936
Diffstat (limited to 'package/switch/src/switch-core.c')
-rw-r--r-- | package/switch/src/switch-core.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/package/switch/src/switch-core.c b/package/switch/src/switch-core.c index f5b248a..79b4e93 100644 --- a/package/switch/src/switch-core.c +++ b/package/switch/src/switch-core.c @@ -341,10 +341,9 @@ switch_vlan_config *switch_parse_vlan(switch_driver *driver, char *buf) switch_vlan_config *c; int j, u, p, s; - c = kmalloc(sizeof(switch_vlan_config), GFP_KERNEL); + c = kzalloc(sizeof(switch_vlan_config), GFP_KERNEL); if (!c) return NULL; - memset(c, 0, sizeof(switch_vlan_config)); while (isspace(*buf)) buf++; j = 0; @@ -382,7 +381,10 @@ switch_vlan_config *switch_parse_vlan(switch_driver *driver, char *buf) while (isspace(*buf)) buf++; } - if (*buf != 0) return NULL; + if (*buf != 0) { + kfree(c); + return NULL; + } c->port &= (1 << driver->ports) - 1; c->untag &= (1 << driver->ports) - 1; |