Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1292260
| From | Ben Hutchings <ben@decadent.org.uk> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: [PATCH 4.3] vrf: Fix memory leak on registration failure in vrf_newlink() |
| Date | 2015-12-15 16:30 +0100 |
| Message-ID | <qFZI5-5X4-11@gated-at.bofh.it> (permalink) |
| References | <qFZyq-5QW-21@gated-at.bofh.it> <qFZyq-5QW-19@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
[Multipart message — attachments visible in raw view] - view raw
On Tue, 2015-12-15 at 08:15 -0700, David Ahern wrote: > On 12/15/15 8:12 AM, Ben Hutchings wrote: > > @@ -598,7 +599,10 @@ static int vrf_newlink(struct net *src_net, struct net_device *dev, > > > > rcu_assign_pointer(dev->vrf_ptr, vrf_ptr); > > > > - return register_netdev(dev); > > + err = register_netdev(dev); > > + if (err) > > + kfree(vrf_ptr); > > + return err; > > } > > > > static size_t vrf_nl_getsize(const struct net_device *dev) > > > > The rcu_assign_pointer should only be done if the register_netdev succeeded. Oh, yes I see. I though that no other task could access an unregistered device, but register_netdev() can still fail after listing the device. Wait, it's worse, this is calling register_netdev() which will deadlock as we already hold the RTNL lock. Ben. > Thanks for creating the patch. > -- Ben Hutchings Logic doesn't apply to the real world. - Marvin Minsky
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Re: [PATCH 4.3] vrf: Fix memory leak on registration failure in vrf_newlink() David Ahern <dsa@cumulusnetworks.com> - 2015-12-15 16:20 +0100
Re: [PATCH 4.3] vrf: Fix memory leak on registration failure in vrf_newlink() Ben Hutchings <ben@decadent.org.uk> - 2015-12-15 16:30 +0100
[PATCH 4.3 2/2] vrf: fix double free and memory corruption on register_netdevice failure Nikolay Aleksandrov <nikolay@cumulusnetworks.com> - 2015-12-15 16:40 +0100
Re: [PATCH 4.3 2/2] vrf: fix double free and memory corruption on register_netdevice failure David Ahern <dsa@cumulusnetworks.com> - 2015-12-15 17:00 +0100
Re: [PATCH 4.3 2/2] vrf: fix double free and memory corruption on register_netdevice failure Ben Hutchings <ben@decadent.org.uk> - 2015-12-15 18:10 +0100
[PATCH 4.3 1/2] Revert "vrf: fix double free and memory corruption on register_netdevice failure" Ben Hutchings <ben@decadent.org.uk> - 2015-12-15 16:40 +0100
Re: [PATCH 4.3 1/2] Revert "vrf: fix double free and memory corruption on register_netdevice failure" David Ahern <dsa@cumulusnetworks.com> - 2015-12-15 16:50 +0100
csiph-web