summaryrefslogtreecommitdiff
path: root/sys/dev/usb
diff options
context:
space:
mode:
authorDamien Bergamini <damien@cvs.openbsd.org>2005-11-23 20:37:38 +0000
committerDamien Bergamini <damien@cvs.openbsd.org>2005-11-23 20:37:38 +0000
commit782fa67eecd6c17731b4d57f238227767c34c8e8 (patch)
tree049da8816d360c3fc18009d2951ee152638cf9dd /sys/dev/usb
parent95c0f3e7eaf3129e265c2e60959801104459a12b (diff)
Be more robust when receiving frames. If we can't allocate a new mbuf,
just discard the received frame and reuse the old mbuf.
Diffstat (limited to 'sys/dev/usb')
-rw-r--r--sys/dev/usb/if_ral.c44
1 files changed, 23 insertions, 21 deletions
diff --git a/sys/dev/usb/if_ral.c b/sys/dev/usb/if_ral.c
index 14e8986f56c..118f0bee9b3 100644
--- a/sys/dev/usb/if_ral.c
+++ b/sys/dev/usb/if_ral.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_ral.c,v 1.48 2005/11/23 20:29:30 damien Exp $ */
+/* $OpenBSD: if_ral.c,v 1.49 2005/11/23 20:37:37 damien Exp $ */
/*-
* Copyright (c) 2005
@@ -877,7 +877,7 @@ ural_rxeof(usbd_xfer_handle xfer, usbd_private_handle priv, usbd_status status)
struct ural_rx_desc *desc;
struct ieee80211_frame *wh;
struct ieee80211_node *ni;
- struct mbuf *m;
+ struct mbuf *mnew, *m;
int s, len;
if (status != USBD_NORMAL_COMPLETION) {
@@ -910,8 +910,28 @@ ural_rxeof(usbd_xfer_handle xfer, usbd_private_handle priv, usbd_status status)
goto skip;
}
- /* finalize mbuf */
+ MGETHDR(mnew, M_DONTWAIT, MT_DATA);
+ if (mnew == NULL) {
+ printf("%s: could not allocate rx mbuf\n",
+ USBDEVNAME(sc->sc_dev));
+ ifp->if_ierrors++;
+ goto skip;
+ }
+
+ MCLGET(mnew, M_DONTWAIT);
+ if (!(mnew->m_flags & M_EXT)) {
+ printf("%s: could not allocate rx mbuf cluster\n",
+ USBDEVNAME(sc->sc_dev));
+ m_freem(mnew);
+ ifp->if_ierrors++;
+ goto skip;
+ }
+
m = data->m;
+ data->m = mnew;
+ data->buf = mtod(data->m, uint8_t *);
+
+ /* finalize mbuf */
m->m_pkthdr.rcvif = ifp;
m->m_pkthdr.len = m->m_len = (letoh32(desc->flags) >> 16) & 0xfff;
m->m_flags |= M_HASFCS; /* hardware appends FCS */
@@ -956,24 +976,6 @@ ural_rxeof(usbd_xfer_handle xfer, usbd_private_handle priv, usbd_status status)
splx(s);
- MGETHDR(data->m, M_DONTWAIT, MT_DATA);
- if (data->m == NULL) {
- printf("%s: could not allocate rx mbuf\n",
- USBDEVNAME(sc->sc_dev));
- return;
- }
-
- MCLGET(data->m, M_DONTWAIT);
- if (!(data->m->m_flags & M_EXT)) {
- printf("%s: could not allocate rx mbuf cluster\n",
- USBDEVNAME(sc->sc_dev));
- m_freem(data->m);
- data->m = NULL;
- return;
- }
-
- data->buf = mtod(data->m, uint8_t *);
-
DPRINTFN(15, ("rx done\n"));
skip: /* setup a new transfer */