Patchwork [net-next,1/8] vxlan: Fix error handling while creating device.

login
register
mail settings
Submitter Pravin B Shelar
Date June 20, 2013, 7:26 a.m.
Message ID <1371713185-8076-1-git-send-email-pshelar@nicira.com>
Download mbox | patch
Permalink /patch/252767/
State Changes Requested
Delegated to: David Miller
Headers show

Comments

Pravin B Shelar - June 20, 2013, 7:26 a.m.
Delete vxlan-sock list entry from list before freeing the memory.

Signed-off-by: Pravin B Shelar <pshelar@nicira.com>
---
 drivers/net/vxlan.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)
stephen hemminger - June 20, 2013, 3:47 p.m.
On Thu, 20 Jun 2013 00:26:25 -0700
Pravin B Shelar <pshelar@nicira.com> wrote:

> Delete vxlan-sock list entry from list before freeing the memory.
> 
> Signed-off-by: Pravin B Shelar <pshelar@nicira.com>
> ---
>  drivers/net/vxlan.c |    4 +++-
>  1 files changed, 3 insertions(+), 1 deletions(-)
> 
> diff --git a/drivers/net/vxlan.c b/drivers/net/vxlan.c
> index 284c6c0..173705f 100644
> --- a/drivers/net/vxlan.c
> +++ b/drivers/net/vxlan.c
> @@ -1606,9 +1606,11 @@ static int vxlan_newlink(struct net *net, struct net_device *dev,
>  	err = register_netdevice(dev);
>  	if (err) {
>  		if (--vs->refcnt == 0) {
> +			hlist_del_rcu(&vs->hlist);
>  			rtnl_unlock();
> +
>  			sk_release_kernel(vs->sock->sk);
> -			kfree(vs);
> +			kfree_rcu(vs, rcu);
>  			rtnl_lock();
>  		}
>  		return err;

This will not be necessary with my next patch set, that code all changes.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Patch

diff --git a/drivers/net/vxlan.c b/drivers/net/vxlan.c
index 284c6c0..173705f 100644
--- a/drivers/net/vxlan.c
+++ b/drivers/net/vxlan.c
@@ -1606,9 +1606,11 @@  static int vxlan_newlink(struct net *net, struct net_device *dev,
 	err = register_netdevice(dev);
 	if (err) {
 		if (--vs->refcnt == 0) {
+			hlist_del_rcu(&vs->hlist);
 			rtnl_unlock();
+
 			sk_release_kernel(vs->sock->sk);
-			kfree(vs);
+			kfree_rcu(vs, rcu);
 			rtnl_lock();
 		}
 		return err;