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 <garyj@munich.netsurf.de>
Submitted by:	Michael Smith <msmith@atrad.adelaide.edu.au>
Obtained from:	NetBSD sources
This commit is contained in:
Nate Williams 1996-08-05 20:52:30 +00:00
parent d8a8289c5a
commit d0dc9fdb98
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=17450
2 changed files with 20 additions and 12 deletions

View file

@ -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 <sys/param.h>
@ -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;
}

View file

@ -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 <sys/param.h>
@ -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;
}