fix null ptr deref when nge_newbuf is called with an existing mbuf

Noticed by:	Coverity Prevent analysis tool
This commit is contained in:
Sam Leffler 2005-03-28 17:49:03 +00:00
parent 9a1c9424cf
commit 6c772336f0
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=144241

View File

@ -1053,23 +1053,21 @@ nge_newbuf(sc, c, m)
struct nge_desc *c;
struct mbuf *m;
{
struct mbuf *m_new = NULL;
if (m == NULL) {
m_new = m_getcl(M_DONTWAIT, MT_DATA, M_PKTHDR);
if (m_new == NULL)
m = m_getcl(M_DONTWAIT, MT_DATA, M_PKTHDR);
if (m == NULL)
return (ENOBUFS);
m = m_new;
} else
m->m_data = m->m_ext.ext_buf;
m->m_len = m->m_pkthdr.len = MCLBYTES;
m_adj(m_new, sizeof(u_int64_t));
m_adj(m, sizeof(u_int64_t));
c->nge_mbuf = m_new;
c->nge_ptr = vtophys(mtod(m_new, caddr_t));
c->nge_ctl = m_new->m_len;
c->nge_mbuf = m;
c->nge_ptr = vtophys(mtod(m, caddr_t));
c->nge_ctl = m->m_len;
c->nge_extsts = 0;
return(0);