mirror of
https://github.com/freebsd/freebsd-src.git
synced 2024-12-04 01:38:57 +00:00
Fix invalid reference of mbuf chains.
Use proper pointer dereference to inform modified mbuf chains to caller. In collaboration with: glebius
This commit is contained in:
parent
d13bfc93ea
commit
ff9c95a4d0
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=161235
@ -2713,7 +2713,7 @@ sk_encap(sc_if, m_head)
|
||||
{
|
||||
struct sk_txdesc *txd;
|
||||
struct sk_tx_desc *f = NULL;
|
||||
struct mbuf *m, *n;
|
||||
struct mbuf *m;
|
||||
bus_dma_segment_t txsegs[SK_MAXTXSEGS];
|
||||
u_int32_t cflags, frag, si, sk_ctl;
|
||||
int error, i, nseg;
|
||||
@ -2723,29 +2723,28 @@ sk_encap(sc_if, m_head)
|
||||
if ((txd = STAILQ_FIRST(&sc_if->sk_cdata.sk_txfreeq)) == NULL)
|
||||
return (ENOBUFS);
|
||||
|
||||
m = *m_head;
|
||||
error = bus_dmamap_load_mbuf_sg(sc_if->sk_cdata.sk_tx_tag,
|
||||
txd->tx_dmamap, m, txsegs, &nseg, 0);
|
||||
txd->tx_dmamap, *m_head, txsegs, &nseg, 0);
|
||||
if (error == EFBIG) {
|
||||
n = m_defrag(m, M_DONTWAIT);
|
||||
if (n == NULL) {
|
||||
m_freem(m);
|
||||
m = NULL;
|
||||
m = m_defrag(*m_head, M_DONTWAIT);
|
||||
if (m == NULL) {
|
||||
m_freem(*m_head);
|
||||
*m_head = NULL;
|
||||
return (ENOMEM);
|
||||
}
|
||||
m = n;
|
||||
*m_head = m;
|
||||
error = bus_dmamap_load_mbuf_sg(sc_if->sk_cdata.sk_tx_tag,
|
||||
txd->tx_dmamap, m, txsegs, &nseg, 0);
|
||||
txd->tx_dmamap, *m_head, txsegs, &nseg, 0);
|
||||
if (error != 0) {
|
||||
m_freem(m);
|
||||
m = NULL;
|
||||
m_freem(*m_head);
|
||||
*m_head = NULL;
|
||||
return (error);
|
||||
}
|
||||
} else if (error != 0)
|
||||
return (error);
|
||||
if (nseg == 0) {
|
||||
m_freem(m);
|
||||
m = NULL;
|
||||
m_freem(*m_head);
|
||||
*m_head = NULL;
|
||||
return (EIO);
|
||||
}
|
||||
if (sc_if->sk_cdata.sk_tx_cnt + nseg >= SK_TX_RING_CNT) {
|
||||
@ -2753,6 +2752,7 @@ sk_encap(sc_if, m_head)
|
||||
return (ENOBUFS);
|
||||
}
|
||||
|
||||
m = *m_head;
|
||||
if ((m->m_pkthdr.csum_flags & sc_if->sk_ifp->if_hwassist) != 0)
|
||||
cflags = SK_OPCODE_CSUM;
|
||||
else
|
||||
|
@ -1206,7 +1206,7 @@ stge_encap(struct stge_softc *sc, struct mbuf **m_head)
|
||||
{
|
||||
struct stge_txdesc *txd;
|
||||
struct stge_tfd *tfd;
|
||||
struct mbuf *m, *n;
|
||||
struct mbuf *m;
|
||||
struct m_tag *mtag;
|
||||
bus_dma_segment_t txsegs[STGE_MAXTXSEGS];
|
||||
int error, i, nsegs, si;
|
||||
@ -1217,32 +1217,32 @@ stge_encap(struct stge_softc *sc, struct mbuf **m_head)
|
||||
if ((txd = STAILQ_FIRST(&sc->sc_cdata.stge_txfreeq)) == NULL)
|
||||
return (ENOBUFS);
|
||||
|
||||
m = *m_head;
|
||||
error = bus_dmamap_load_mbuf_sg(sc->sc_cdata.stge_tx_tag,
|
||||
txd->tx_dmamap, m, txsegs, &nsegs, 0);
|
||||
txd->tx_dmamap, *m_head, txsegs, &nsegs, 0);
|
||||
if (error == EFBIG) {
|
||||
n = m_defrag(m, M_DONTWAIT);
|
||||
if (n == NULL) {
|
||||
m_freem(m);
|
||||
m = NULL;
|
||||
m = m_defrag(*m_head, M_DONTWAIT);
|
||||
if (m == NULL) {
|
||||
m_freem(*m_head);
|
||||
*m_head = NULL;
|
||||
return (ENOMEM);
|
||||
}
|
||||
m = n;
|
||||
*m_head = m;
|
||||
error = bus_dmamap_load_mbuf_sg(sc->sc_cdata.stge_tx_tag,
|
||||
txd->tx_dmamap, m, txsegs, &nsegs, 0);
|
||||
txd->tx_dmamap, *m_head, txsegs, &nsegs, 0);
|
||||
if (error != 0) {
|
||||
m_freem(m);
|
||||
m = NULL;
|
||||
m_freem(*m_head);
|
||||
*m_head = NULL;
|
||||
return (error);
|
||||
}
|
||||
} else if (error != 0)
|
||||
return (error);
|
||||
if (nsegs == 0) {
|
||||
m_freem(m);
|
||||
m = NULL;
|
||||
m_freem(*m_head);
|
||||
*m_head = NULL;
|
||||
return (EIO);
|
||||
}
|
||||
|
||||
m = *m_head;
|
||||
csum_flags = 0;
|
||||
if ((m->m_pkthdr.csum_flags & STGE_CSUM_FEATURES) != 0) {
|
||||
if (m->m_pkthdr.csum_flags & CSUM_IP)
|
||||
|
Loading…
Reference in New Issue
Block a user