summaryrefslogtreecommitdiff
path: root/sys/dev
diff options
context:
space:
mode:
authorChris Cappuccio <chris@cvs.openbsd.org>2013-01-17 21:49:49 +0000
committerChris Cappuccio <chris@cvs.openbsd.org>2013-01-17 21:49:49 +0000
commitc3ad589762aab529f28b7537effca3da332d9b1e (patch)
treec1c0b4383e363153367e86a0409bbe0e5eda486c /sys/dev
parent87dce307d2cae1cb29db06fde6cb5f5ed683de39 (diff)
Don't try to access m_head after it may be freed (unlikely for VT6105M,
but possible). Also don't re-calculate vlan tag repeatedly through the descriptor loop. ok dtucker@
Diffstat (limited to 'sys/dev')
-rw-r--r--sys/dev/pci/if_vr.c21
1 files changed, 11 insertions, 10 deletions
diff --git a/sys/dev/pci/if_vr.c b/sys/dev/pci/if_vr.c
index 37a0e040e00..477965cdee8 100644
--- a/sys/dev/pci/if_vr.c
+++ b/sys/dev/pci/if_vr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_vr.c,v 1.124 2013/01/16 06:15:50 dtucker Exp $ */
+/* $OpenBSD: if_vr.c,v 1.125 2013/01/17 21:49:48 chris Exp $ */
/*
* Copyright (c) 1997, 1998
@@ -1249,6 +1249,16 @@ vr_encap(struct vr_softc *sc, struct vr_chain **cp, struct mbuf *m_head)
return(1);
}
+#if NVLAN > 0
+ /* Tell chip to insert VLAN tag if needed. */
+ if (m_head->m_flags & M_VLANTAG) {
+ u_int32_t vtag = m_head->m_pkthdr.ether_vtag;
+ vtag = (vtag << VR_TXSTAT_PQSHIFT) & VR_TXSTAT_PQMASK;
+ vr_status |= vtag;
+ vr_ctl |= htole32(VR_TXCTL_INSERTTAG);
+ }
+#endif
+
if (m_new != NULL) {
m_freem(m_head);
@@ -1257,15 +1267,6 @@ vr_encap(struct vr_softc *sc, struct vr_chain **cp, struct mbuf *m_head)
c->vr_mbuf = m_head;
txmap = c->vr_map;
for (i = 0; i < txmap->dm_nsegs; i++) {
-#if NVLAN > 0
- /* Tell chip to insert VLAN tag if needed. */
- if (m_head->m_flags & M_VLANTAG) {
- u_int32_t vtag = m_head->m_pkthdr.ether_vtag;
- vtag = (vtag << VR_TXSTAT_PQSHIFT) & VR_TXSTAT_PQMASK;
- vr_status |= vtag;
- vr_ctl |= htole32(VR_TXCTL_INSERTTAG);
- }
-#endif
if (i != 0)
*cp = c = c->vr_nextdesc;
f = c->vr_ptr;