ppp: PR1943: Avoid NULL pointer access

Waiting for mbufs at this level is a bad solution.  It would be better
to try to allocate a new mbuf chain before we hand over the current mbuf
chain to the upper layer.  In case the allocation fails we should drop
the current packet and use its mbuf chain for a new packet.
This commit is contained in:
Sebastian Huber
2014-10-08 11:43:10 +02:00
committed by Gedare Bloom
parent b47dffc510
commit d1d31a5f61

View File

@@ -708,14 +708,8 @@ pppallocmbuf(struct ppp_softc *sc, struct mbuf **mp)
m = *mp;
if ( m == NULL ) {
/* get mbuf header */
MGETHDR(m, M_DONTWAIT, MT_DATA);
if ( m == NULL ) {
/* error - set condition to break out */
printf("pppallocmbuf: MGETHDR failed\n");
break;
}
MCLGET(m, M_DONTWAIT);
m->m_next = NULL;
MGETHDR(m, M_WAIT, MT_DATA);
MCLGET(m, M_WAIT);
*mp = m;
}