From owner-svn-src-head@FreeBSD.ORG Tue Feb 24 06:08:56 2015 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 5F90C301; Tue, 24 Feb 2015 06:08:56 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::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 30A8BF9C; Tue, 24 Feb 2015 06:08:56 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id t1O68u3F003032; Tue, 24 Feb 2015 06:08:56 GMT (envelope-from arybchik@FreeBSD.org) Received: (from arybchik@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id t1O68uxG003031; Tue, 24 Feb 2015 06:08:56 GMT (envelope-from arybchik@FreeBSD.org) Message-Id: <201502240608.t1O68uxG003031@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: arybchik set sender to arybchik@FreeBSD.org using -f From: Andrew Rybchenko Date: Tue, 24 Feb 2015 06:08:56 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r279230 - head/sys/dev/sfxge X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 Feb 2015 06:08:56 -0000 Author: arybchik Date: Tue Feb 24 06:08:55 2015 New Revision: 279230 URL: https://svnweb.freebsd.org/changeset/base/279230 Log: sfxge: use goto to cleanup to avoid duplicate cleanup code Sponsored by: Solarflare Communications, Inc. Approved by: gnn (mentor) Modified: head/sys/dev/sfxge/sfxge_dma.c Modified: head/sys/dev/sfxge/sfxge_dma.c ============================================================================== --- head/sys/dev/sfxge/sfxge_dma.c Tue Feb 24 05:43:16 2015 (r279229) +++ head/sys/dev/sfxge/sfxge_dma.c Tue Feb 24 06:08:55 2015 (r279230) @@ -141,7 +141,7 @@ sfxge_dma_alloc(struct sfxge_softc *sc, MIN(0x3FFFFFFFFFFFUL, BUS_SPACE_MAXADDR), BUS_SPACE_MAXADDR, NULL, NULL, len, 1, len, 0, NULL, NULL, &esmp->esm_tag) != 0) { device_printf(sc->dev, "Couldn't allocate txq DMA tag\n"); - return (ENOMEM); + goto fail_tag_create; } /* Allocate kernel memory. */ @@ -149,17 +149,14 @@ sfxge_dma_alloc(struct sfxge_softc *sc, BUS_DMA_WAITOK | BUS_DMA_COHERENT | BUS_DMA_ZERO, &esmp->esm_map) != 0) { device_printf(sc->dev, "Couldn't allocate DMA memory\n"); - bus_dma_tag_destroy(esmp->esm_tag); - return (ENOMEM); + goto fail_alloc; } /* Load map into device memory. */ if (bus_dmamap_load(esmp->esm_tag, esmp->esm_map, vaddr, len, sfxge_dma_cb, &esmp->esm_addr, 0) != 0) { device_printf(sc->dev, "Couldn't load DMA mapping\n"); - bus_dmamem_free(esmp->esm_tag, vaddr, esmp->esm_map); - bus_dma_tag_destroy(esmp->esm_tag); - return (ENOMEM); + goto fail_load; } /* @@ -167,15 +164,20 @@ sfxge_dma_alloc(struct sfxge_softc *sc, * and will have set esm_addr to 0 if something went * wrong. */ - if (esmp->esm_addr == 0) { - bus_dmamem_free(esmp->esm_tag, vaddr, esmp->esm_map); - bus_dma_tag_destroy(esmp->esm_tag); - return (ENOMEM); - } + if (esmp->esm_addr == 0) + goto fail_load_check; esmp->esm_base = vaddr; return (0); + +fail_load_check: +fail_load: + bus_dmamem_free(esmp->esm_tag, vaddr, esmp->esm_map); +fail_alloc: + bus_dma_tag_destroy(esmp->esm_tag); +fail_tag_create: + return (ENOMEM); } void