diff options
author | Kenneth R Westerback <krw@cvs.openbsd.org> | 2005-03-27 16:14:44 +0000 |
---|---|---|
committer | Kenneth R Westerback <krw@cvs.openbsd.org> | 2005-03-27 16:14:44 +0000 |
commit | a63d839b7a4981e0a891868c8b363232c2e20607 (patch) | |
tree | 7688ab288bce9913c497b7ba3da6c056ece28576 | |
parent | ce1113627749371a5de4f8367cc6b8ccef222216 (diff) |
Fix possible double alignment, and a memory leak in error path. Mostly
from FreeBSD.
ok brad@.
-rw-r--r-- | sys/dev/pci/if_bge.c | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/sys/dev/pci/if_bge.c b/sys/dev/pci/if_bge.c index 0690a1a6d1a..b19f2f9d985 100644 --- a/sys/dev/pci/if_bge.c +++ b/sys/dev/pci/if_bge.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_bge.c,v 1.54 2005/03/07 18:59:11 brad Exp $ */ +/* $OpenBSD: if_bge.c,v 1.55 2005/03/27 16:14:43 krw Exp $ */ /* * Copyright (c) 2001 Wind River Systems * Copyright (c) 1997, 1998, 1999, 2001 @@ -749,15 +749,19 @@ bge_newbuf_std(sc, i, m) m_new->m_data = m_new->m_ext.ext_buf; } - if (bus_dmamap_load_mbuf(sc->bge_dmatag, rxmap, m_new, BUS_DMA_NOWAIT)) - return(ENOBUFS); - if (!sc->bge_rx_alignment_bug) m_adj(m_new, ETHER_ALIGN); + + if (bus_dmamap_load_mbuf(sc->bge_dmatag, rxmap, m_new, + BUS_DMA_NOWAIT)) { + if (m == NULL) + m_freem(m_new); + return(ENOBUFS); + } + sc->bge_cdata.bge_rx_std_chain[i] = m_new; r = &sc->bge_rdata->bge_rx_std_ring[i]; - BGE_HOSTADDR(r->bge_addr, rxmap->dm_segs[0].ds_addr + - (sc->bge_rx_alignment_bug ? 0 : ETHER_ALIGN)); + BGE_HOSTADDR(r->bge_addr, rxmap->dm_segs[0].ds_addr); r->bge_flags = BGE_RXBDFLAG_END; r->bge_len = m_new->m_len; r->bge_idx = i; |