summaryrefslogtreecommitdiff
path: root/sys/dev
diff options
context:
space:
mode:
authorClaudio Jeker <claudio@cvs.openbsd.org>2007-07-31 22:01:38 +0000
committerClaudio Jeker <claudio@cvs.openbsd.org>2007-07-31 22:01:38 +0000
commita210e3010a168e566799b81f4131147f0230866c (patch)
tree48cb34cc134c31aab130a1cfce4c9d6f053b5978 /sys/dev
parent09b5445141f84d01c2504c6c9ba37e3451105c68 (diff)
Plug a mbuf leak in the TX path and replace a handbuilt m_copydata()
implementation with m_copydata(). Remove the CMALO_DEBUG that slipped in somehow. OK mglocker@
Diffstat (limited to 'sys/dev')
-rw-r--r--sys/dev/pcmcia/if_malo.c16
1 files changed, 5 insertions, 11 deletions
diff --git a/sys/dev/pcmcia/if_malo.c b/sys/dev/pcmcia/if_malo.c
index 48a4f5c41b6..5e5516b7374 100644
--- a/sys/dev/pcmcia/if_malo.c
+++ b/sys/dev/pcmcia/if_malo.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_malo.c,v 1.25 2007/07/31 14:57:58 mglocker Exp $ */
+/* $OpenBSD: if_malo.c,v 1.26 2007/07/31 22:01:37 claudio Exp $ */
/*
* Copyright (c) 2007 Marcus Glocker <mglocker@openbsd.org>
@@ -59,7 +59,6 @@
* Driver for the Marvell 88W8385 CF chip.
*/
-#define CMALO_DEBUG
#ifdef CMALO_DEBUG
int cmalo_d = 2;
#define DPRINTF(l, x...) do { if ((l) <= cmalo_d) printf(x); } while (0)
@@ -908,10 +907,9 @@ cmalo_tx(struct malo_softc *sc, struct mbuf *m)
{
struct ifnet *ifp = &sc->sc_ic.ic_if;
struct malo_tx_desc *txdesc = sc->sc_data;
- struct mbuf *m0;
uint8_t *data;
uint16_t psize, *uc;
- int i, off;
+ int i;
bzero(sc->sc_data, sizeof(*txdesc));
psize = sizeof(*txdesc) + m->m_pkthdr.len;
@@ -923,12 +921,8 @@ cmalo_tx(struct malo_softc *sc, struct mbuf *m)
bcopy(data, txdesc->dstaddrhigh, ETHER_ADDR_LEN);
/* copy mbuf data to the buffer */
- off = sizeof(*txdesc);
- for (m0 = m; m0; m0 = m0->m_next) {
- data = mtod(m0, uint8_t *);
- bcopy(data, sc->sc_data + off, m0->m_len);
- off += m0->m_len;
- }
+ m_copydata(m, 0, m->m_pkthdr.len, sc->sc_data + sizeof(*txdesc));
+ m_freem(m);
/* send TX packet to the device */
MALO_WRITE_2(sc, MALO_REG_DATA_WRITE_LEN, psize);
@@ -943,7 +937,7 @@ cmalo_tx(struct malo_softc *sc, struct mbuf *m)
ifp->if_flags |= IFF_OACTIVE;
DPRINTF(2, "%s: TX status=%d, pkglen=%d, pkgoffset=%d\n",
- sc->sc_dev.dv_xname, txdesc->status, m->m_pkthdr.len,
+ sc->sc_dev.dv_xname, txdesc->status, letoh16(txdesc->pkglen),
sizeof(*txdesc));
return (0);