WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-changelog

[Xen-changelog] [NET] front: Network devices need to be freed by free_ne

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [NET] front: Network devices need to be freed by free_netdev not kfree.
From: Xen patchbot-unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Thu, 18 May 2006 10:58:13 +0000
Delivery-date: Thu, 18 May 2006 04:00:09 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# 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

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] [NET] front: Network devices need to be freed by free_netdev not kfree., Xen patchbot-unstable <=