Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 3 Oct 2015 15:58:01 +0000 (UTC)
From:      Adrian Chadd <adrian@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r288606 - head/sys/dev/usb/wlan
Message-ID:  <201510031558.t93Fw1o2077431@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
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:	<s3erios@gmail.com>
  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



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