summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarkus Friedl <markus@cvs.openbsd.org>2004-03-02 23:09:30 +0000
committerMarkus Friedl <markus@cvs.openbsd.org>2004-03-02 23:09:30 +0000
commit7f16c5207e0c3867ab527eb90fe75d1dbf4e64d9 (patch)
tree4c449d80b99e4b68953620849a978643d562cf52
parent0b1e72aafd52e0b289d8959f0d461e79eda23b82 (diff)
don't leak mbuf if uiomove fails; from netbsd;
ok henning, cedric, claudio, deraadt
-rw-r--r--sys/net/if_tun.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/sys/net/if_tun.c b/sys/net/if_tun.c
index 91e1d4e3723..c5e40909ca1 100644
--- a/sys/net/if_tun.c
+++ b/sys/net/if_tun.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_tun.c,v 1.57 2004/01/12 04:48:25 tedu Exp $ */
+/* $OpenBSD: if_tun.c,v 1.58 2004/03/02 23:09:29 markus Exp $ */
/* $NetBSD: if_tun.c,v 1.24 1996/05/07 02:40:48 thorpej Exp $ */
/*
@@ -729,7 +729,7 @@ tunwrite(dev, uio, ioflag)
error = uiomove(mtod (m, caddr_t), m->m_len, uio);
*mp = m;
mp = &m->m_next;
- if (uio->uio_resid > 0) {
+ if (error == 0 && uio->uio_resid > 0) {
MGET (m, M_DONTWAIT, MT_DATA);
if (m == 0) {
error = ENOBUFS;