From owner-svn-src-all@freebsd.org Mon Oct 19 14:47:38 2015 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 74F48A1983A; Mon, 19 Oct 2015 14:47:38 +0000 (UTC) (envelope-from royger@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 40D4510D1; Mon, 19 Oct 2015 14:47:38 +0000 (UTC) (envelope-from royger@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id t9JElbNO022059; Mon, 19 Oct 2015 14:47:37 GMT (envelope-from royger@FreeBSD.org) Received: (from royger@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id t9JElbNe022058; Mon, 19 Oct 2015 14:47:37 GMT (envelope-from royger@FreeBSD.org) Message-Id: <201510191447.t9JElbNe022058@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: royger set sender to royger@FreeBSD.org using -f From: =?UTF-8?Q?Roger_Pau_Monn=c3=a9?= Date: Mon, 19 Oct 2015 14:47:37 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r289589 - head/sys/dev/xen/netfront X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 19 Oct 2015 14:47:38 -0000 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 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); }