ia64/xen-unstable

changeset 10092:843b9ef21352

[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@osdl.org>
author kaf24@firebug.cl.cam.ac.uk
date Thu May 18 10:12:07 2006 +0100 (2006-05-18)
parents 65421cc6d86b
children 6f957675015d
files linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c
line diff
     1.1 --- a/linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c	Thu May 18 10:06:52 2006 +0100
     1.2 +++ b/linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c	Thu May 18 10:12:07 2006 +0100
     1.3 @@ -223,7 +223,8 @@ static int __devinit netfront_probe(stru
     1.4  
     1.5  	err = talk_to_backend(dev, info);
     1.6  	if (err) {
     1.7 -		kfree(info);
     1.8 +		unregister_netdev(netdev);
     1.9 +		free_netdev(netdev);
    1.10  		dev->data = NULL;
    1.11  		return err;
    1.12  	}
    1.13 @@ -1101,11 +1102,11 @@ static int __devinit create_netdev(int h
    1.14  	struct net_device *netdev = NULL;
    1.15  	struct netfront_info *np = NULL;
    1.16  
    1.17 -	if ((netdev = alloc_etherdev(sizeof(struct netfront_info))) == NULL) {
    1.18 +	netdev = alloc_etherdev(sizeof(struct netfront_info));
    1.19 +	if (!netdev) {
    1.20  		printk(KERN_WARNING "%s> alloc_etherdev failed.\n",
    1.21  		       __FUNCTION__);
    1.22 -		err = -ENOMEM;
    1.23 -		goto exit;
    1.24 +		return -ENOMEM;
    1.25  	}
    1.26  
    1.27  	np                = netdev_priv(netdev);
    1.28 @@ -1149,7 +1150,7 @@ static int __devinit create_netdev(int h
    1.29  		printk(KERN_ALERT "#### netfront can't alloc rx grant refs\n");
    1.30  		gnttab_free_grant_references(np->gref_tx_head);
    1.31  		err = -ENOMEM;
    1.32 -		goto exit;
    1.33 +		goto exit_free_tx;
    1.34  	}
    1.35  
    1.36  	netdev->open            = network_open;
    1.37 @@ -1169,27 +1170,28 @@ static int __devinit create_netdev(int h
    1.38  	if ((err = register_netdev(netdev)) != 0) {
    1.39  		printk(KERN_WARNING "%s> register_netdev err=%d\n",
    1.40  		       __FUNCTION__, err);
    1.41 -		goto exit_free_grefs;
    1.42 +		goto exit_free_rx;
    1.43  	}
    1.44  
    1.45  	if ((err = xennet_proc_addif(netdev)) != 0) {
    1.46  		unregister_netdev(netdev);
    1.47 -		goto exit_free_grefs;
    1.48 +		goto exit_free_rx;
    1.49  	}
    1.50  
    1.51  	np->netdev = netdev;
    1.52 -
    1.53 - exit:
    1.54 -	if (err != 0)
    1.55 -		kfree(netdev);
    1.56 -	else if (val != NULL)
    1.57 +	if (val)
    1.58  		*val = netdev;
    1.59 -	return err;
    1.60 +
    1.61 +	return 0;
    1.62 +
    1.63  
    1.64 - exit_free_grefs:
    1.65 + exit_free_rx:
    1.66 +	gnttab_free_grant_references(np->gref_rx_head);
    1.67 + exit_free_tx:
    1.68  	gnttab_free_grant_references(np->gref_tx_head);
    1.69 -	gnttab_free_grant_references(np->gref_rx_head);
    1.70 -	goto exit;
    1.71 + exit:
    1.72 +	free_netdev(netdev);
    1.73 +	return err;
    1.74  }
    1.75  
    1.76  /*