From d0dc9fdb986d53b0b9c248c3b46777786bc413c6 Mon Sep 17 00:00:00 2001 From: Nate Williams Date: Mon, 5 Aug 1996 20:52:30 +0000 Subject: [PATCH] Fix memory leak bug in the path parsing code which never released it's buffer in certain error conditions. Sync up the code to that in NetBSD where applicable. Reviewed by: Gary Jennejohn Submitted by: Michael Smith Obtained from: NetBSD sources --- sys/compat/linux/linux_util.c | 16 ++++++++++------ sys/i386/linux/linux_util.c | 16 ++++++++++------ 2 files changed, 20 insertions(+), 12 deletions(-) diff --git a/sys/compat/linux/linux_util.c b/sys/compat/linux/linux_util.c index 1785fd315a10..bc4efddd005b 100644 --- a/sys/compat/linux/linux_util.c +++ b/sys/compat/linux/linux_util.c @@ -27,7 +27,7 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * from: svr4_util.c,v 1.5 1995/01/22 23:44:50 christos Exp - * $Id$ + * $Id: linux_util.c,v 1.1 1996/03/02 19:38:02 peter Exp $ */ #include @@ -146,18 +146,18 @@ linux_emul_find(p, sgp, prefix, path, pbuf, cflag) } if ((error = VOP_GETATTR(nd.ni_vp, &vat, p->p_ucred, p)) != 0) { - goto done; + goto bad; } if ((error = VOP_GETATTR(ndroot.ni_vp, &vatroot, p->p_ucred, p)) != 0) { - goto done; + goto bad; } if (vat.va_fsid == vatroot.va_fsid && vat.va_fileid == vatroot.va_fileid) { error = ENOENT; - goto done; + goto bad; } } @@ -170,10 +170,14 @@ linux_emul_find(p, sgp, prefix, path, pbuf, cflag) free(buf, M_TEMP); } - -done: vrele(nd.ni_vp); if (!cflag) vrele(ndroot.ni_vp); return error; + +bad: + vrele(ndroot.ni_vp); + vrele(nd.ni_vp); + free(buf, M_TEMP); + return error; } diff --git a/sys/i386/linux/linux_util.c b/sys/i386/linux/linux_util.c index 1785fd315a10..bc4efddd005b 100644 --- a/sys/i386/linux/linux_util.c +++ b/sys/i386/linux/linux_util.c @@ -27,7 +27,7 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * from: svr4_util.c,v 1.5 1995/01/22 23:44:50 christos Exp - * $Id$ + * $Id: linux_util.c,v 1.1 1996/03/02 19:38:02 peter Exp $ */ #include @@ -146,18 +146,18 @@ linux_emul_find(p, sgp, prefix, path, pbuf, cflag) } if ((error = VOP_GETATTR(nd.ni_vp, &vat, p->p_ucred, p)) != 0) { - goto done; + goto bad; } if ((error = VOP_GETATTR(ndroot.ni_vp, &vatroot, p->p_ucred, p)) != 0) { - goto done; + goto bad; } if (vat.va_fsid == vatroot.va_fsid && vat.va_fileid == vatroot.va_fileid) { error = ENOENT; - goto done; + goto bad; } } @@ -170,10 +170,14 @@ linux_emul_find(p, sgp, prefix, path, pbuf, cflag) free(buf, M_TEMP); } - -done: vrele(nd.ni_vp); if (!cflag) vrele(ndroot.ni_vp); return error; + +bad: + vrele(ndroot.ni_vp); + vrele(nd.ni_vp); + free(buf, M_TEMP); + return error; }