diff -ru /cvs/sys_old/dev/musycc/musycc.c /usr/src/sys/dev/musycc/musycc.c --- /cvs/sys_old/dev/musycc/musycc.c Sun Dec 24 16:00:48 2000 +++ /usr/src/sys/dev/musycc/musycc.c Sun Dec 24 20:09:33 2000 @@ -1208,7 +1208,35 @@ sc->mdt[ch][i].data = 0; MGETHDR(m, M_TRYWAIT, MT_DATA); + if (m == NULL) { + /* We've waited mbuf_wait and still got nothing. */ + /* We're calling with M_TRYWAIT anyway - a little + defensive programming costs us very little - if + almost nothing. */ + while (i > 0) { + /* Don't leak all the previously allocated + mbufs in this loop. */ + i--; + m_free(sc->mdr[ch][i].m); + } + FREE(sc->mdt[ch], M_MUSYCC); + FREE(sc->mdr[ch], M_MUSYCC); + return ENOBUFS; + } MCLGET(m, M_TRYWAIT); + if ((m->m_ext & M_EXT) == 0) { + /* We've waited mbuf_wait and still got nothing. */ + while (i > 0) { + /* Don't leak all the previously allocated + mbufs in this loop. */ + i--; + m_free(sc->mdr[ch][i].m); + } + FREE(sc->mdt[ch], M_MUSYCC); + FREE(sc->mdr[ch], M_MUSYCC); + m_free(m); + return ENOBUFS; + } sc->mdr[ch][i].m = m; sc->mdr[ch][i].data = vtophys(m->m_data); sc->mdr[ch][i].status = 1600; /* MTU */