[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] [NET] front: Network devices need to be freed by free_netdev not kfree.



# HG changeset patch
# User kaf24@xxxxxxxxxxxxxxxxxxxx
# Node ID 843b9ef21352584a5587a8c390214959284f0024
# Parent  65421cc6d86baec5b8710aff06aa655afe9094c6
[NET] front: Network devices need to be freed by free_netdev not kfree.
Also, fix some missing unwinds in error path.
Still not convinced there aren't some lurking double free's in the error
paths here.

Signed-off-by: Stephen Hemminger <shemminger@xxxxxxxx>
---
 linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c |   36 ++++++++++---------
 1 files changed, 19 insertions(+), 17 deletions(-)

diff -r 65421cc6d86b -r 843b9ef21352 
linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c
--- a/linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c      Thu May 18 
10:06:52 2006 +0100
+++ b/linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c      Thu May 18 
10:12:07 2006 +0100
@@ -223,7 +223,8 @@ static int __devinit netfront_probe(stru
 
        err = talk_to_backend(dev, info);
        if (err) {
-               kfree(info);
+               unregister_netdev(netdev);
+               free_netdev(netdev);
                dev->data = NULL;
                return err;
        }
@@ -1101,11 +1102,11 @@ static int __devinit create_netdev(int h
        struct net_device *netdev = NULL;
        struct netfront_info *np = NULL;
 
-       if ((netdev = alloc_etherdev(sizeof(struct netfront_info))) == NULL) {
+       netdev = alloc_etherdev(sizeof(struct netfront_info));
+       if (!netdev) {
                printk(KERN_WARNING "%s> alloc_etherdev failed.\n",
                       __FUNCTION__);
-               err = -ENOMEM;
-               goto exit;
+               return -ENOMEM;
        }
 
        np                = netdev_priv(netdev);
@@ -1149,7 +1150,7 @@ static int __devinit create_netdev(int h
                printk(KERN_ALERT "#### netfront can't alloc rx grant refs\n");
                gnttab_free_grant_references(np->gref_tx_head);
                err = -ENOMEM;
-               goto exit;
+               goto exit_free_tx;
        }
 
        netdev->open            = network_open;
@@ -1169,27 +1170,28 @@ static int __devinit create_netdev(int h
        if ((err = register_netdev(netdev)) != 0) {
                printk(KERN_WARNING "%s> register_netdev err=%d\n",
                       __FUNCTION__, err);
-               goto exit_free_grefs;
+               goto exit_free_rx;
        }
 
        if ((err = xennet_proc_addif(netdev)) != 0) {
                unregister_netdev(netdev);
-               goto exit_free_grefs;
+               goto exit_free_rx;
        }
 
        np->netdev = netdev;
-
+       if (val)
+               *val = netdev;
+
+       return 0;
+
+
+ exit_free_rx:
+       gnttab_free_grant_references(np->gref_rx_head);
+ exit_free_tx:
+       gnttab_free_grant_references(np->gref_tx_head);
  exit:
-       if (err != 0)
-               kfree(netdev);
-       else if (val != NULL)
-               *val = netdev;
+       free_netdev(netdev);
        return err;
-
- exit_free_grefs:
-       gnttab_free_grant_references(np->gref_tx_head);
-       gnttab_free_grant_references(np->gref_rx_head);
-       goto exit;
 }
 
 /*

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.