Li RongQing
2018-Oct-15 11:00 UTC
[Bridge] [PATCH][net-next][v2] 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: 9163a0fc1f0c0 ("net: bridge: add support for per-port vlan stats") CC: bridge at lists.linux-foundation.org cc: Nikolay Aleksandrov <nikolay at cumulusnetworks.com> CC: Roopa Prabhu <roopa at cumulusnetworks.com> Signed-off-by: Zhang Yu <zhangyu31 at baidu.com> Signed-off-by: Li RongQing <lirongqing at baidu.com> --- net/bridge/br_vlan.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/net/bridge/br_vlan.c b/net/bridge/br_vlan.c index 9b707234e4ae..8c9297a01947 100644 --- a/net/bridge/br_vlan.c +++ b/net/bridge/br_vlan.c @@ -303,6 +303,10 @@ static int __vlan_add(struct net_bridge_vlan *v, u16 flags) if (p) { __vlan_vid_del(dev, br, v->vid); if (masterv) { + if (v->stats && masterv->stats != v->stats) + free_percpu(v->stats); + v->stats = NULL; + br_vlan_put_master(masterv); v->brvlan = NULL; } -- 2.16.2
Nikolay Aleksandrov
2018-Oct-15 11:13 UTC
[Bridge] [PATCH][net-next][v2] net: bridge: fix a possible memory leak in __vlan_add
On 15/10/2018 14:00, Li RongQing wrote:> After per-port vlan stats, vlan stats should be released > when fail to add vlan > > Fixes: 9163a0fc1f0c0 ("net: bridge: add support for per-port vlan stats") > CC: bridge at lists.linux-foundation.org > cc: Nikolay Aleksandrov <nikolay at cumulusnetworks.com> > CC: Roopa Prabhu <roopa at cumulusnetworks.com> > Signed-off-by: Zhang Yu <zhangyu31 at baidu.com> > Signed-off-by: Li RongQing <lirongqing at baidu.com> > --- > net/bridge/br_vlan.c | 4 ++++ > 1 file changed, 4 insertions(+) > > diff --git a/net/bridge/br_vlan.c b/net/bridge/br_vlan.c > index 9b707234e4ae..8c9297a01947 100644 > --- a/net/bridge/br_vlan.c > +++ b/net/bridge/br_vlan.c > @@ -303,6 +303,10 @@ static int __vlan_add(struct net_bridge_vlan *v, u16 flags) > if (p) { > __vlan_vid_del(dev, br, v->vid); > if (masterv) { > + if (v->stats && masterv->stats != v->stats) > + free_percpu(v->stats); > + v->stats = NULL; > + > br_vlan_put_master(masterv); > v->brvlan = NULL; > } >Thanks, Signed-off-by: Nikolay Aleksandrov <nikolay at cumulusnetworks.com>
David Miller
2018-Oct-16 05:55 UTC
[Bridge] [PATCH][net-next][v2] net: bridge: fix a possible memory leak in __vlan_add
From: Li RongQing <lirongqing at baidu.com> Date: Mon, 15 Oct 2018 19:00:31 +0800> After per-port vlan stats, vlan stats should be released > when fail to add vlan > > Fixes: 9163a0fc1f0c0 ("net: bridge: add support for per-port vlan stats") > CC: bridge at lists.linux-foundation.org > cc: Nikolay Aleksandrov <nikolay at cumulusnetworks.com> > CC: Roopa Prabhu <roopa at cumulusnetworks.com> > Signed-off-by: Zhang Yu <zhangyu31 at baidu.com> > Signed-off-by: Li RongQing <lirongqing at baidu.com>Applied.