Avoid an unnecessary API difference between NetBSD and FreeBSD:

back out my change to ieee80211_crypto_encap that made it free its
mbuf argument on error.  I had thought it was a bug.  It was not.
It's the drivers that are broken.  Make an(4), atw(4), ipw(4),
iwi(4), ral(4), rtw(4), ural(4), and wi(4) free the mbuf when
ieee80211_crypto_encap returns NULL.  Also, return ath(4) to the
way it was---i.e., free the mbuf.

Thanks to Sam Leffler to pointing out my mistake.
This commit is contained in:
dyoung 2005-07-06 23:44:15 +00:00
parent f44b62c49d
commit 707b2b4ae1
6 changed files with 23 additions and 16 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: ral.c,v 1.2 2005/07/04 17:50:10 drochner Exp $ */
/* $NetBSD: ral.c,v 1.3 2005/07/06 23:44:15 dyoung Exp $ */
/* $OpenBSD: ral.c,v 1.55 2005/06/20 18:25:10 damien Exp $ */
/*-
@ -24,7 +24,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: ral.c,v 1.2 2005/07/04 17:50:10 drochner Exp $");
__KERNEL_RCSID(0, "$NetBSD: ral.c,v 1.3 2005/07/06 23:44:15 dyoung Exp $");
#include "bpfilter.h"
@ -1814,8 +1814,10 @@ ral_tx_data(struct ral_softc *sc, struct mbuf *m0, struct ieee80211_node *ni)
if (wh->i_fc[1] & IEEE80211_FC1_WEP) {
k = ieee80211_crypto_encap(ic, ni, m0);
if (k == NULL)
if (k == NULL) {
m_freem(m0);
return ENOBUFS;
}
/* packet header may have moved, reset our local pointer */
wh = mtod(m0, struct ieee80211_frame *);

View File

@ -1,4 +1,4 @@
/* $NetBSD: rtw.c,v 1.50 2005/06/28 07:19:33 dyoung Exp $ */
/* $NetBSD: rtw.c,v 1.51 2005/07/06 23:44:16 dyoung Exp $ */
/*-
* Copyright (c) 2004, 2005 David Young. All rights reserved.
*
@ -34,7 +34,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: rtw.c,v 1.50 2005/06/28 07:19:33 dyoung Exp $");
__KERNEL_RCSID(0, "$NetBSD: rtw.c,v 1.51 2005/07/06 23:44:16 dyoung Exp $");
#include "bpfilter.h"
@ -3104,6 +3104,7 @@ rtw_start(struct ifnet *ifp)
if ((wh->i_fc[1] & IEEE80211_FC1_WEP) != 0 &&
(k = ieee80211_crypto_encap(ic, ni, m0)) == NULL) {
m_freem(m0);
break;
} else
k = NULL;

View File

@ -1,4 +1,4 @@
/* $NetBSD: wi.c,v 1.202 2005/07/06 06:49:25 dyoung Exp $ */
/* $NetBSD: wi.c,v 1.203 2005/07/06 23:44:16 dyoung Exp $ */
/*-
* Copyright (c) 2004 The NetBSD Foundation, Inc.
@ -106,7 +106,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: wi.c,v 1.202 2005/07/06 06:49:25 dyoung Exp $");
__KERNEL_RCSID(0, "$NetBSD: wi.c,v 1.203 2005/07/06 23:44:16 dyoung Exp $");
#define WI_HERMES_AUTOINC_WAR /* Work around data write autoinc bug. */
#define WI_HERMES_STATS_WAR /* Work around stats counter bug. */
@ -1133,6 +1133,7 @@ wi_start(struct ifnet *ifp)
if (ic->ic_opmode == IEEE80211_M_HOSTAP &&
(wh->i_fc[1] & IEEE80211_FC1_WEP)) {
if (ieee80211_crypto_encap(ic, ni, m0) == NULL) {
m_freem(m0);
ifp->if_oerrors++;
goto next;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: if_ipw.c,v 1.12 2005/06/22 06:16:02 dyoung Exp $ */
/* $NetBSD: if_ipw.c,v 1.13 2005/07/06 23:44:15 dyoung Exp $ */
/*-
* Copyright (c) 2004
@ -28,7 +28,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: if_ipw.c,v 1.12 2005/06/22 06:16:02 dyoung Exp $");
__KERNEL_RCSID(0, "$NetBSD: if_ipw.c,v 1.13 2005/07/06 23:44:15 dyoung Exp $");
/*-
* Intel(R) PRO/Wireless 2100 MiniPCI driver
@ -723,8 +723,10 @@ ipw_tx_start(struct ifnet *ifp, struct mbuf *m, struct ieee80211_node *ni)
iswep = (wh->i_fc[1] & IEEE80211_FC1_WEP) ? 1 : 0;
if (iswep && (k = ieee80211_crypto_encap(ic, ni, m)) == NULL)
if (iswep && (k = ieee80211_crypto_encap(ic, ni, m)) == NULL) {
m_freem(m);
return EIO;
}
#if NBPFILTER > 0
if (sc->sc_drvbpf != NULL) {

View File

@ -1,4 +1,4 @@
/* $NetBSD: if_ural.c,v 1.2 2005/07/04 17:46:31 drochner Exp $ */
/* $NetBSD: if_ural.c,v 1.3 2005/07/06 23:44:17 dyoung Exp $ */
/* $OpenBSD: if_ral.c,v 1.36 2005/06/20 18:54:59 damien Exp $ */
/*-
@ -24,7 +24,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: if_ural.c,v 1.2 2005/07/04 17:46:31 drochner Exp $");
__KERNEL_RCSID(0, "$NetBSD: if_ural.c,v 1.3 2005/07/06 23:44:17 dyoung Exp $");
#include "bpfilter.h"
@ -1241,8 +1241,10 @@ ural_tx_data(struct ural_softc *sc, struct mbuf *m0, struct ieee80211_node *ni)
if (wh->i_fc[1] & IEEE80211_FC1_WEP) {
k = ieee80211_crypto_encap(ic, ni, m0);
if (k == NULL)
if (k == NULL) {
m_freem(m0);
return ENOBUFS;
}
/* packet header may have moved, reset our local pointer */
wh = mtod(m0, struct ieee80211_frame *);

View File

@ -1,4 +1,4 @@
/* $NetBSD: ieee80211_crypto.c,v 1.7 2005/06/22 06:16:02 dyoung Exp $ */
/* $NetBSD: ieee80211_crypto.c,v 1.8 2005/07/06 23:44:15 dyoung Exp $ */
/*-
* Copyright (c) 2001 Atsushi Onoe
* Copyright (c) 2002-2005 Sam Leffler, Errno Consulting
@ -36,7 +36,7 @@
__FBSDID("$FreeBSD: src/sys/net80211/ieee80211_crypto.c,v 1.7 2004/12/31 22:42:38 sam Exp $");
#endif
#ifdef __NetBSD__
__KERNEL_RCSID(0, "$NetBSD: ieee80211_crypto.c,v 1.7 2005/06/22 06:16:02 dyoung Exp $");
__KERNEL_RCSID(0, "$NetBSD: ieee80211_crypto.c,v 1.8 2005/07/06 23:44:15 dyoung Exp $");
#endif
#include "opt_inet.h"
@ -542,7 +542,6 @@ ieee80211_crypto_encap(struct ieee80211com *ic,
if (cip->ic_encap(k, m, keyid<<6))
return k;
bad:
m_freem(m);
return NULL;
}