All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net v4 00/12] Fix possbile memleaks when fail to register_netdevice
@ 2017-05-02  5:58 gfree.wind
  2017-05-02  5:58 ` [PATCH net v4 01/12] driver: dummy: Fix one possbile memleak " gfree.wind
                   ` (14 more replies)
  0 siblings, 15 replies; 18+ messages in thread
From: gfree.wind @ 2017-05-02  5:58 UTC (permalink / raw)
  To: davem, jiri, mareklindner, sw, a, kuznet, jmorris, yoshfuji,
	kaber, steffen.klassert, herbert, netdev
  Cc: Gao Feng

From: Gao Feng <gfree.wind@foxmail.com>

These following drivers allocate kinds of resources in its ndo_init
func, free some of them or all in the destructor func. Then there is
one memleak that some errors happen after register_netdevice invokes
the ndo_init callback. Because only the ndo_uninit callback is invoked
in the error handler of register_netdevice, but destructor not.

In my original approach, I tried to free the resources in the newlink
func when fail to register_netdevice, like destructor did except not
free the net_dev. This method is not good when destructor is changed,
and the memleak could be not fixed when there is no newlink callback.

Now create one new func used to free the resources in the destructor,
and the ndo_uninit func also could invokes it when fail to register
the net_device by comparing the dev->reg_state with NETREG_UNINITIALIZED.
If there is no existing ndo_uninit, just add one.

This solution doesn't only make sure free all resources in any case,
but also follows the original desgin that some resources could be kept
until the destructor executes normally after register the device
successfully.

Gao Feng (12):
  driver: dummy: Fix one possbile memleak when fail to
    register_netdevice
  driver: ifb: Fix one possbile memleak when fail to register_netdevice
  driver: loopback: Fix one possbile memleak when fail to
    register_netdevice
  driver: team: Fix one possbile memleak when fail to register_netdevice
  driver: veth: Fix one possbile memleak when fail to register_netdevice
  net: ip6_gre: Fix one possbile memleak when fail to register_netdevice
  ip6_tunnel: Fix one possbile memleak when fail to register_netdevice
  net: ip6_vti: Fix one possbile memleak when fail to register_netdevice
  net: ip_tunnel: Fix one possbile memleak when fail to
    register_netdevice
  net: sit: Fix one possbile memleak when fail to register_netdevice
  net: vlan: Fix one possbile memleak when fail to register_netdevice
  net: batman-adv: Fix one possbile memleak when fail to
    register_netdevice

 drivers/net/dummy.c             | 14 +++++++++++---
 drivers/net/ifb.c               | 33 +++++++++++++++++++++++----------
 drivers/net/loopback.c          | 15 ++++++++++++++-
 drivers/net/team/team.c         | 15 ++++++++++++---
 drivers/net/veth.c              | 15 ++++++++++++++-
 net/8021q/vlan_dev.c            | 17 +++++++++++++----
 net/batman-adv/soft-interface.c | 18 +++++++++++++++---
 net/ipv4/ip_tunnel.c            | 11 ++++++++++-
 net/ipv6/ip6_gre.c              | 17 +++++++++++++----
 net/ipv6/ip6_tunnel.c           | 11 ++++++++++-
 net/ipv6/ip6_vti.c              | 11 ++++++++++-
 net/ipv6/sit.c                  | 17 +++++++++++++----
 12 files changed, 158 insertions(+), 36 deletions(-)

^ permalink raw reply	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2017-05-08  4:19 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-05-02  5:58 [PATCH net v4 00/12] Fix possbile memleaks when fail to register_netdevice gfree.wind
2017-05-02  5:58 ` [PATCH net v4 01/12] driver: dummy: Fix one possbile memleak " gfree.wind
2017-05-02  5:58 ` [PATCH net v4 02/12] driver: ifb: " gfree.wind
2017-05-02  5:58 ` [PATCH net v4 03/12] driver: loopback: " gfree.wind
2017-05-02  5:58 ` [PATCH net v4 04/12] driver: team: " gfree.wind
2017-05-02  5:58 ` [PATCH net v4 05/12] driver: veth: " gfree.wind
2017-05-02  5:58 ` [PATCH net v4 06/12] net: ip6_gre: " gfree.wind
2017-05-02  6:59 ` [PATCH net v4 07/12] ip6_tunnel: " gfree.wind
2017-05-02 11:10 ` [PATCH net v4 00/12] Fix possbile memleaks " Gao Feng
2017-05-02 13:34 ` [PATCH net v4 08/12] net: ip6_vti: Fix one possbile memleak " gfree.wind
2017-05-02 13:37 ` [PATCH net v4 09/12] net: ip_tunnel: " gfree.wind
2017-05-02 13:39 ` [PATCH net v4 10/12] net: sit: " gfree.wind
2017-05-02 13:41 ` [PATCH net v4 11/12] net: vlan: " gfree.wind
2017-05-02 14:17 ` [PATCH net v4 12/12] net: batman-adv: " gfree.wind
2017-05-02 19:30 ` [PATCH net v4 00/12] Fix possbile memleaks " David Miller
2017-05-03  0:33   ` Gao Feng
2017-05-07 22:25 ` David Miller
2017-05-08  4:18   ` Gao Feng

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.