On Tue, Apr 25, 2017 at 08:01:50PM +0800, gfree.w...@foxmail.com wrote:
> From: Gao Feng <f...@ikuai8.com>
> 
> These drivers allocate kinds of resources in init routine, and free
> some resources in the destructor of net_device. It may cause memleak
> when some errors happen after register_netdevice invokes the init
> callback. Because only the uninit callback is invoked in the error
> handler of register_netdevice, but the destructor not. As a result,
> some resources are lost forever.
> 
> Now invokes the destructor instead of free_netdev somewhere, and free
> the left resources in the newlink func when fail to register_netdevice.
> 
> Signed-off-by: Gao Feng <f...@ikuai8.com>

This has the potential of creating future bugs, because there
is no guarantee that the ndo_init function has been invoked at
all.

Wouldn't it be safer to move the freeing from the destructors
into their ndo_uninit functions instead?

Thanks,
-- 
Email: Herbert Xu <herb...@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

Reply via email to