Skip to content

Commit 1a3aea2

Browse files
lrq-maxdavem330
authored andcommitted
net: bridge: fix a possible memory leak in __vlan_add
After per-port vlan stats, vlan stats should be released when fail to add vlan Fixes: 9163a0f ("net: bridge: add support for per-port vlan stats") CC: bridge@lists.linux-foundation.org cc: Nikolay Aleksandrov <nikolay@cumulusnetworks.com> CC: Roopa Prabhu <roopa@cumulusnetworks.com> Signed-off-by: Zhang Yu <zhangyu31@baidu.com> Signed-off-by: Li RongQing <lirongqing@baidu.com> Signed-off-by: Nikolay Aleksandrov <nikolay@cumulusnetworks.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent bc0e7cf commit 1a3aea2

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

net/bridge/br_vlan.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,10 @@ static int __vlan_add(struct net_bridge_vlan *v, u16 flags)
303303
if (p) {
304304
__vlan_vid_del(dev, br, v->vid);
305305
if (masterv) {
306+
if (v->stats && masterv->stats != v->stats)
307+
free_percpu(v->stats);
308+
v->stats = NULL;
309+
306310
br_vlan_put_master(masterv);
307311
v->brvlan = NULL;
308312
}

0 commit comments

Comments
 (0)