|
|
|
|
|
|
|
|
|
|
xen-devel
[Xen-devel] [PATCH 4/6] netfront: use free_netdev and other unwinds
# HG changeset patch
# User shemminger@xxxxxxxxxxxxxxxxxxxxx
# Node ID 06cea5a9cbae9af028300e470849bc034beaff75
# Parent 44ad0558e50c91ad66a155c017d6df0cb36e007d
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>
diff -r 44ad0558e50c -r 06cea5a9cbae
linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c
--- a/linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c Wed May 17
20:44:25 2006
+++ b/linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c Wed May 17
20:48:41 2006
@@ -229,7 +229,8 @@
err = talk_to_backend(dev, info);
if (err) {
- kfree(info);
+ unregister_netdev(netdev);
+ free_netdev(netdev);
dev->data = NULL;
return err;
}
@@ -1119,11 +1120,11 @@
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);
@@ -1168,7 +1169,7 @@
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;
@@ -1197,18 +1198,19 @@
}
np->netdev = netdev;
-
+ if (val)
+ *val = netdev;
+
+ return 0;
+
+
+ exit_free_grefs:
+ 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-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel
|
|
|
|
|