diff mbox series

net-veth: Fix memleak in veth_newlink

Message ID 20201022054233.17326-1-dinghao.liu@zju.edu.cn
State Rejected
Delegated to: David Miller
Headers show
Series net-veth: Fix memleak in veth_newlink | expand

Checks

Context Check Description
jkicinski/stable success Stable not CCed
jkicinski/header_inline success Link
jkicinski/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
jkicinski/checkpatch success total: 0 errors, 0 warnings, 0 checks, 8 lines checked
jkicinski/verify_fixes success Link
jkicinski/kdoc success Errors and warnings before: 0 this patch: 0
jkicinski/build_32bit success Errors and warnings before: 0 this patch: 0
jkicinski/module_param success Was 0 now: 0
jkicinski/verify_signedoff success Link
jkicinski/source_inline success Was 0 now: 0
jkicinski/subject_prefix warning Target tree name not specified in the subject
jkicinski/tree_selection success Guessed tree name to be net-next
jkicinski/patch_count success Link
jkicinski/fixes_present success Link
jkicinski/cover_letter success Link

Commit Message

Dinghao Liu Oct. 22, 2020, 5:42 a.m. UTC
When rtnl_configure_link() fails, peer needs to be
freed just like when register_netdevice() fails.

Signed-off-by: Dinghao Liu <dinghao.liu@zju.edu.cn>
---
 drivers/net/veth.c | 2 --
 1 file changed, 2 deletions(-)

Comments

Jakub Kicinski Oct. 22, 2020, 4:12 p.m. UTC | #1
On Thu, 22 Oct 2020 13:42:33 +0800 Dinghao Liu wrote:
> When rtnl_configure_link() fails, peer needs to be
> freed just like when register_netdevice() fails.
> 
> Signed-off-by: Dinghao Liu <dinghao.liu@zju.edu.cn>

Can you see this leak or are you just sending this based on your
reading of the code?

netdev should be freed by the core:

static void veth_setup(struct net_device *dev)                                  
{                                                                               
        ether_setup(dev);                                                       
                                                                                
	[...]                    
        dev->needs_free_netdev = true;    

> diff --git a/drivers/net/veth.c b/drivers/net/veth.c
> index 8c737668008a..6c68094399cc 100644
> --- a/drivers/net/veth.c
> +++ b/drivers/net/veth.c
> @@ -1405,8 +1405,6 @@ static int veth_newlink(struct net *src_net, struct net_device *dev,
>  	/* nothing to do */
>  err_configure_peer:
>  	unregister_netdevice(peer);
> -	return err;
> -
>  err_register_peer:
>  	free_netdev(peer);
>  	return err;
diff mbox series

Patch

diff --git a/drivers/net/veth.c b/drivers/net/veth.c
index 8c737668008a..6c68094399cc 100644
--- a/drivers/net/veth.c
+++ b/drivers/net/veth.c
@@ -1405,8 +1405,6 @@  static int veth_newlink(struct net *src_net, struct net_device *dev,
 	/* nothing to do */
 err_configure_peer:
 	unregister_netdevice(peer);
-	return err;
-
 err_register_peer:
 	free_netdev(peer);
 	return err;