diff options
author | Hauke Mehrtens <hauke@openwrt.org> | 2012-01-28 13:52:37 +0000 |
---|---|---|
committer | Hauke Mehrtens <hauke@openwrt.org> | 2012-01-28 13:52:37 +0000 |
commit | b8d85a12121adf2bb2a637f86eb0def57b78791c (patch) | |
tree | 6437a44ec74955df0f617cb8ef03afebd93bb9fb /package/switch | |
parent | c003d83f1ae5887b0e50ea7a2945f20044df1503 (diff) | |
download | master-187ad058-b8d85a12121adf2bb2a637f86eb0def57b78791c.tar.gz master-187ad058-b8d85a12121adf2bb2a637f86eb0def57b78791c.tar.bz2 master-187ad058-b8d85a12121adf2bb2a637f86eb0def57b78791c.zip |
switch: fix some memory leaks in switch_parse_vlan()
git-svn-id: svn://svn.openwrt.org/openwrt/trunk@29936 3c298f89-4303-0410-b956-a3cf2f4a3e73
Diffstat (limited to 'package/switch')
-rw-r--r-- | package/switch/src/switch-adm.c | 1 | ||||
-rw-r--r-- | package/switch/src/switch-core.c | 8 | ||||
-rw-r--r-- | package/switch/src/switch-robo.c | 6 |
3 files changed, 8 insertions, 7 deletions
diff --git a/package/switch/src/switch-adm.c b/package/switch/src/switch-adm.c index 2aff14207b..3826ca57f8 100644 --- a/package/switch/src/switch-adm.c +++ b/package/switch/src/switch-adm.c @@ -341,6 +341,7 @@ static int handle_vlan_port_write(void *driver, char *buf, int nr) } adm_wreg(0x13 + nr, (__u16) ports); + kfree(c); return 0; } diff --git a/package/switch/src/switch-core.c b/package/switch/src/switch-core.c index f5b248aadb..79b4e93f03 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; diff --git a/package/switch/src/switch-robo.c b/package/switch/src/switch-robo.c index ec9e337337..7bac91942a 100644 --- a/package/switch/src/switch-robo.c +++ b/package/switch/src/switch-robo.c @@ -459,6 +459,7 @@ static int handle_vlan_port_write(void *driver, char *buf, int nr) robo_write32(ROBO_ARLIO_PAGE, 0x63 + regoff, (c->untag << 9) | c->port); robo_write16(ROBO_ARLIO_PAGE, 0x61 + regoff, nr); robo_write16(ROBO_ARLIO_PAGE, 0x60 + regoff, 1 << 7); + kfree(c); return 0; } @@ -473,6 +474,7 @@ static int handle_vlan_port_write(void *driver, char *buf, int nr) robo_write16(ROBO_VLAN_PAGE, ROBO_VLAN_TABLE_ACCESS, val16); } + kfree(c); return 0; } @@ -520,13 +522,9 @@ static int handle_enable_vlan_write(void *driver, char *buf, int nr) static int handle_reset(void *driver, char *buf, int nr) { switch_driver *d = (switch_driver *) driver; - switch_vlan_config *c = switch_parse_vlan(d, buf); int j; __u16 val16; - if (c == NULL) - return -EINVAL; - /* disable switching */ set_switch(0); |