Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 19 Oct 2015 14:47:37 +0000 (UTC)
From:      =?UTF-8?Q?Roger_Pau_Monn=c3=a9?= <royger@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r289589 - head/sys/dev/xen/netfront
Message-ID:  <201510191447.t9JElbNe022058@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: royger
Date: Mon Oct 19 14:47:37 2015
New Revision: 289589
URL: https://svnweb.freebsd.org/changeset/base/289589

Log:
  xen-netfront: fix netfront create_dev error path
  
  The failure path for allocating rx grant refs should not try to free tx
  grant refs because tx grant refs were allocated after that. Also fix the
  error path for xen_net_read_mac.
  
  Submitted by:		Wei Liu <wei.liu2@citrix.com>
  Reviewed by:		royger
  Differential Revision:	https://reviews.freebsd.org/D3891
  Sponsored by:		Citrix Systems R&D

Modified:
  head/sys/dev/xen/netfront/netfront.c

Modified: head/sys/dev/xen/netfront/netfront.c
==============================================================================
--- head/sys/dev/xen/netfront/netfront.c	Mon Oct 19 14:37:17 2015	(r289588)
+++ head/sys/dev/xen/netfront/netfront.c	Mon Oct 19 14:47:37 2015	(r289589)
@@ -1885,7 +1885,7 @@ create_netdev(device_t dev)
 					  &np->gref_tx_head) != 0) {
 		IPRINTK("#### netfront can't alloc tx grant refs\n");
 		err = ENOMEM;
-		goto exit;
+		goto error;
 	}
 	/* A grant for every rx ring slot */
 	if (gnttab_alloc_grant_references(RX_MAX_TARGET,
@@ -1893,12 +1893,15 @@ create_netdev(device_t dev)
 		WPRINTK("#### netfront can't alloc rx grant refs\n");
 		gnttab_free_grant_references(np->gref_tx_head);
 		err = ENOMEM;
-		goto exit;
+		goto error;
 	}
 
 	err = xen_net_read_mac(dev, np->mac);
-	if (err)
-		goto out;
+	if (err) {
+		gnttab_free_grant_references(np->gref_rx_head);
+		gnttab_free_grant_references(np->gref_tx_head);
+		goto error;
+	}
 
 	/* Set up ifnet structure */
 	ifp = np->xn_ifp = if_alloc(IFT_ETHER);
@@ -1925,9 +1928,8 @@ create_netdev(device_t dev)
 
 	return (0);
 
-exit:
-	gnttab_free_grant_references(np->gref_tx_head);
-out:
+error:
+	KASSERT(err != 0, ("Error path with no error code specified"));
 	return (err);
 }
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201510191447.t9JElbNe022058>