diff options
author | kmacy <kmacy@FreeBSD.org> | 2007-04-20 05:06:02 +0000 |
---|---|---|
committer | kmacy <kmacy@FreeBSD.org> | 2007-04-20 05:06:02 +0000 |
commit | f49e46301bf3d9f4f0e996f82f92cb65c9fc7f3c (patch) | |
tree | 8948f35a9fb53fd9a65e5e046312b8de07d3e57c /sys/dev | |
parent | d1c72876f0f97720eb5651593b507d785c266ac8 (diff) | |
download | FreeBSD-src-f49e46301bf3d9f4f0e996f82f92cb65c9fc7f3c.zip FreeBSD-src-f49e46301bf3d9f4f0e996f82f92cb65c9fc7f3c.tar.gz |
Fix memory leak in m_collapse (CID 1843)
Found by: Coverity
Submitted by: jhb
Diffstat (limited to 'sys/dev')
-rw-r--r-- | sys/dev/cxgb/sys/uipc_mvec.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/sys/dev/cxgb/sys/uipc_mvec.c b/sys/dev/cxgb/sys/uipc_mvec.c index aec78b1..bbe6b76 100644 --- a/sys/dev/cxgb/sys/uipc_mvec.c +++ b/sys/dev/cxgb/sys/uipc_mvec.c @@ -258,7 +258,7 @@ _m_collapse(struct mbuf *m, int maxbufs, struct mbuf **mnew) { struct mbuf *m0, *lmvec[MAX_BUFS]; struct mbuf **mnext; - struct mbuf **vec = &lmvec[0]; + struct mbuf **vec = lmvec; struct mbuf *mhead = NULL; struct mbuf_vec *mv; int err, i, j, max, len, nhbufs; @@ -273,9 +273,9 @@ _m_collapse(struct mbuf *m, int maxbufs, struct mbuf **mnew) } if ((err = m_vectorize(m, maxbufs, vec, &max)) != 0) - return (err); + goto out; if ((err = m_findmbufs(vec, max, dvec, MAX_HVEC, &nhbufs)) != 0) - return (err); + goto out; KASSERT(max > 0, ("invalid mbuf count")); KASSERT(nhbufs > 0, ("invalid header mbuf count")); @@ -322,7 +322,10 @@ _m_collapse(struct mbuf *m, int maxbufs, struct mbuf **mnew) } *mnew = mhead; - return (0); +out: + if (vec != lmvec) + free(vec, M_DEVBUF); + return (err); } void |