From owner-svn-src-head@freebsd.org Sat Oct 3 15:58:01 2015 Return-Path: Delivered-To: svn-src-head@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 5414FA0D3D0; Sat, 3 Oct 2015 15:58:01 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from repo.freebsd.org (repo.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 358811088; Sat, 3 Oct 2015 15:58:01 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.70]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id t93Fw1lw077432; Sat, 3 Oct 2015 15:58:01 GMT (envelope-from adrian@FreeBSD.org) Received: (from adrian@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id t93Fw1o2077431; Sat, 3 Oct 2015 15:58:01 GMT (envelope-from adrian@FreeBSD.org) Message-Id: <201510031558.t93Fw1o2077431@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: adrian set sender to adrian@FreeBSD.org using -f From: Adrian Chadd Date: Sat, 3 Oct 2015 15:58:01 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r288606 - head/sys/dev/usb/wlan 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.20 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: Sat, 03 Oct 2015 15:58:01 -0000 Author: adrian Date: Sat Oct 3 15:58:00 2015 New Revision: 288606 URL: https://svnweb.freebsd.org/changeset/base/288606 Log: rum(4): simplify error handling rum_raw_xmit() Move the mbuf free responsibility to the caller of the hardware xmit function, not the hardware xmit function itself. Submitted by: Differential Revision: https://reviews.freebsd.org/D3621 Modified: head/sys/dev/usb/wlan/if_rum.c Modified: head/sys/dev/usb/wlan/if_rum.c ============================================================================== --- head/sys/dev/usb/wlan/if_rum.c Sat Oct 3 15:52:58 2015 (r288605) +++ head/sys/dev/usb/wlan/if_rum.c Sat Oct 3 15:58:00 2015 (r288606) @@ -1157,10 +1157,9 @@ rum_tx_mgt(struct rum_softc *sc, struct wh = mtod(m0, struct ieee80211_frame *); if (wh->i_fc[1] & IEEE80211_FC1_PROTECTED) { k = ieee80211_crypto_encap(ni, m0); - if (k == NULL) { - m_freem(m0); - return ENOBUFS; - } + if (k == NULL) + return (ENOBUFS); + wh = mtod(m0, struct ieee80211_frame *); } @@ -1205,13 +1204,11 @@ rum_tx_raw(struct rum_softc *sc, struct int rate, error; RUM_LOCK_ASSERT(sc); - KASSERT(params != NULL, ("no raw xmit params")); rate = params->ibp_rate0; - if (!ieee80211_isratevalid(ic->ic_rt, rate)) { - m_freem(m0); - return EINVAL; - } + if (!ieee80211_isratevalid(ic->ic_rt, rate)) + return (EINVAL); + flags = 0; if ((params->ibp_flags & IEEE80211_BPF_NOACK) == 0) flags |= RT2573_TX_NEED_ACK; @@ -1220,10 +1217,9 @@ rum_tx_raw(struct rum_softc *sc, struct params->ibp_flags & IEEE80211_BPF_RTS ? IEEE80211_PROT_RTSCTS : IEEE80211_PROT_CTSONLY, rate); - if (error || sc->tx_nfree == 0) { - m_freem(m0); - return ENOBUFS; - } + if (error || sc->tx_nfree == 0) + return (ENOBUFS); + flags |= RT2573_TX_LONG_RETRY | RT2573_TX_IFS_SIFS; } @@ -2224,20 +2220,17 @@ rum_raw_xmit(struct ieee80211_node *ni, const struct ieee80211_bpf_params *params) { struct rum_softc *sc = ni->ni_ic->ic_softc; + int ret; RUM_LOCK(sc); /* prevent management frames from being sent if we're not ready */ if (!sc->sc_running) { - RUM_UNLOCK(sc); - m_freem(m); - ieee80211_free_node(ni); - return ENETDOWN; + ret = ENETDOWN; + goto bad; } if (sc->tx_nfree < RUM_TX_MINFREE) { - RUM_UNLOCK(sc); - m_freem(m); - ieee80211_free_node(ni); - return EIO; + ret = EIO; + goto bad; } if (params == NULL) { @@ -2245,14 +2238,14 @@ rum_raw_xmit(struct ieee80211_node *ni, * Legacy path; interpret frame contents to decide * precisely how to send the frame. */ - if (rum_tx_mgt(sc, m, ni) != 0) + if ((ret = rum_tx_mgt(sc, m, ni)) != 0) goto bad; } else { /* * Caller supplied explicit parameters to use in * sending the frame. */ - if (rum_tx_raw(sc, m, ni, params) != 0) + if ((ret = rum_tx_raw(sc, m, ni, params)) != 0) goto bad; } RUM_UNLOCK(sc); @@ -2260,8 +2253,9 @@ rum_raw_xmit(struct ieee80211_node *ni, return 0; bad: RUM_UNLOCK(sc); + m_freem(m); ieee80211_free_node(ni); - return EIO; + return ret; } static void