From owner-svn-src-all@freebsd.org Thu Jun 16 17:59:16 2016 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 A0785A77251; Thu, 16 Jun 2016 17:59:16 +0000 (UTC) (envelope-from adrian@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 71F2B1886; Thu, 16 Jun 2016 17:59:16 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u5GHxFMu077215; Thu, 16 Jun 2016 17:59:15 GMT (envelope-from adrian@FreeBSD.org) Received: (from adrian@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5GHxFaX077214; Thu, 16 Jun 2016 17:59:15 GMT (envelope-from adrian@FreeBSD.org) Message-Id: <201606161759.u5GHxFaX077214@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: adrian set sender to adrian@FreeBSD.org using -f From: Adrian Chadd Date: Thu, 16 Jun 2016 17:59:15 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r301970 - head/sys/dev/iwm 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.22 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: Thu, 16 Jun 2016 17:59:16 -0000 Author: adrian Date: Thu Jun 16 17:59:15 2016 New Revision: 301970 URL: https://svnweb.freebsd.org/changeset/base/301970 Log: [iwm] free RX ring / NVM memory after they're used. * Free RX ring during detach * Free NVM memory after parsing Tested: * 7260, STA mode Submitted by: Imre Vadasz Approved by: re (gjb) Obtained from: dragonflybsd Differential Revision: https://reviews.freebsd.org/D6817 Modified: head/sys/dev/iwm/if_iwm.c Modified: head/sys/dev/iwm/if_iwm.c ============================================================================== --- head/sys/dev/iwm/if_iwm.c Thu Jun 16 16:26:16 2016 (r301969) +++ head/sys/dev/iwm/if_iwm.c Thu Jun 16 17:59:15 2016 (r301970) @@ -1823,7 +1823,7 @@ iwm_parse_nvm_data(struct iwm_softc *sc, struct iwm_nvm_section { uint16_t length; - const uint8_t *data; + uint8_t *data; }; static int @@ -1860,6 +1860,8 @@ iwm_nvm_init(struct iwm_softc *sc) "%s: Read NVM\n", __func__); + memset(nvm_sections, 0, sizeof(nvm_sections)); + /* TODO: find correct NVM max size for a section */ nvm_buffer = malloc(IWM_OTP_LOW_IMAGE_SIZE, M_DEVBUF, M_NOWAIT); if (nvm_buffer == NULL) @@ -1883,10 +1885,15 @@ iwm_nvm_init(struct iwm_softc *sc) nvm_sections[section].length = len; } free(nvm_buffer, M_DEVBUF); - if (error) - return error; + if (error == 0) + error = iwm_parse_nvm_sections(sc, nvm_sections); - return iwm_parse_nvm_sections(sc, nvm_sections); + for (i = 0; i < IWM_NVM_NUM_OF_SECTIONS; i++) { + if (nvm_sections[i].data != NULL) + free(nvm_sections[i].data, M_DEVBUF); + } + + return error; } /* @@ -5008,6 +5015,7 @@ iwm_detach_local(struct iwm_softc *sc, i ieee80211_ifdetach(&sc->sc_ic); /* Free descriptor rings */ + iwm_free_rx_ring(sc, &sc->rxq); for (i = 0; i < nitems(sc->txq); i++) iwm_free_tx_ring(sc, &sc->txq[i]);