Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1388889 > unrolled thread
| Started by | Haishuang Yan <yanhaishuang@cmss.chinamobile.com> |
|---|---|
| First post | 2016-04-27 12:50 +0200 |
| Last post | 2016-04-27 13:00 +0200 |
| Articles | 2 — 2 participants |
Back to article view | Back to linux.kernel
[PATCH] veth: Fix potential memory leak in veth_newlink Haishuang Yan <yanhaishuang@cmss.chinamobile.com> - 2016-04-27 12:50 +0200
Re: [PATCH] veth: Fix potential memory leak in veth_newlink Nikolay Aleksandrov <nikolay@cumulusnetworks.com> - 2016-04-27 13:00 +0200
| From | Haishuang Yan <yanhaishuang@cmss.chinamobile.com> |
|---|---|
| Date | 2016-04-27 12:50 +0200 |
| Subject | [PATCH] veth: Fix potential memory leak in veth_newlink |
| Message-ID | <rsvcC-8ae-21@gated-at.bofh.it> |
Free peer netdev when failed to configure peer link or register dev. Signed-off-by: Haishuang Yan <yanhaishuang@cmss.chinamobile.com> --- drivers/net/veth.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/net/veth.c b/drivers/net/veth.c index f37a6e6..8bb9fb8 100644 --- a/drivers/net/veth.c +++ b/drivers/net/veth.c @@ -472,7 +472,6 @@ err_register_dev: /* nothing to do */ err_configure_peer: unregister_netdevice(peer); - return err; err_register_peer: free_netdev(peer); -- 1.8.3.1
[toc] | [next] | [standalone]
| From | Nikolay Aleksandrov <nikolay@cumulusnetworks.com> |
|---|---|
| Date | 2016-04-27 13:00 +0200 |
| Message-ID | <rsvmi-8dS-9@gated-at.bofh.it> |
| In reply to | #1388889 |
On 04/27/2016 12:42 PM, Haishuang Yan wrote: > Free peer netdev when failed to configure peer link or register dev. > > Signed-off-by: Haishuang Yan <yanhaishuang@cmss.chinamobile.com> > --- > drivers/net/veth.c | 1 - > 1 file changed, 1 deletion(-) > > diff --git a/drivers/net/veth.c b/drivers/net/veth.c > index f37a6e6..8bb9fb8 100644 > --- a/drivers/net/veth.c > +++ b/drivers/net/veth.c > @@ -472,7 +472,6 @@ err_register_dev: > /* nothing to do */ > err_configure_peer: > unregister_netdevice(peer); > - return err; > > err_register_peer: > free_netdev(peer); > No, it won't leak. unregister_netdevice() will queue it on the todo list and at the next rtnl unlock the peer device will get freed. In fact calling it like this you'll hit BUG_ON(dev->reg_state != NETREG_UNREGISTERED) in free_netdev so I guess you didn't even test your patch.
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web