diff options
author | jhb <jhb@FreeBSD.org> | 2003-03-21 21:49:52 +0000 |
---|---|---|
committer | jhb <jhb@FreeBSD.org> | 2003-03-21 21:49:52 +0000 |
commit | 1b63f61cec2a3043a56cb3f14d862c35d6d61e35 (patch) | |
tree | a99d15c729b3ffc82c0707f779c6af090ed723c6 /sys/alpha | |
parent | a56305572587eb0a4e0d7793a845b70c41bafa8c (diff) | |
download | FreeBSD-src-1b63f61cec2a3043a56cb3f14d862c35d6d61e35.zip FreeBSD-src-1b63f61cec2a3043a56cb3f14d862c35d6d61e35.tar.gz |
Fix some memory leaks in the failure cases after trying to look up the
OSF/1 runtime loader. Also, use td_ucred instead of p_ucred.
Tested by: gallatin
Reviewed by: rwatson
Diffstat (limited to 'sys/alpha')
-rw-r--r-- | sys/alpha/osf1/imgact_osf1.c | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/sys/alpha/osf1/imgact_osf1.c b/sys/alpha/osf1/imgact_osf1.c index d633182..2bb97b8 100644 --- a/sys/alpha/osf1/imgact_osf1.c +++ b/sys/alpha/osf1/imgact_osf1.c @@ -96,12 +96,14 @@ exec_osf1_imgact(struct image_params *imgp) vm_offset_t tsize; struct nameidata *ndp; Osf_Auxargs *osf_auxargs; + struct thread *td; GIANT_REQUIRED; execp = (const struct ecoff_exechdr*)imgp->image_header; eap = &execp->a; ndp = NULL; + td = FIRST_THREAD_IN_PROC(imgp->proc); /* check to make sure we have an alpha ecoff executable */ if (ECOFF_BADMAG(execp)) @@ -137,14 +139,15 @@ exec_osf1_imgact(struct image_params *imgp) ndp = (struct nameidata *)malloc(sizeof(struct nameidata), M_TEMP, M_WAITOK); NDINIT(ndp, LOOKUP, LOCKLEAF | FOLLOW | SAVENAME, UIO_SYSSPACE, - "/compat/osf1/sbin/loader", - FIRST_THREAD_IN_PROC(imgp->proc)); + "/compat/osf1/sbin/loader", td); error = namei(ndp); if (error) { uprintf("imgact_osf1: can't read /compat/osf1/sbin/loader\n"); free(imgp->auxargs, M_TEMP); + free(ndp, M_TEMP); return(error); - } + } + NDFREE(ndp, NDF_ONLY_PNBUF); if (imgp->vp) { vput(imgp->vp); /* leaking in the nameizone ??? XXX */ @@ -192,7 +195,7 @@ exec_osf1_imgact(struct image_params *imgp) VM_PROT_READ|VM_PROT_EXECUTE, VM_PROT_ALL, MAP_FIXED|MAP_COPY, (caddr_t)imgp->vp, ECOFF_TXTOFF(execp)))) { DPRINTF(("%s(%d): error = %d\n", __FILE__, __LINE__, error)); - return error; + goto bail; } /* .. data .. */ if ((error = vm_mmap(&vmspace->vm_map, &daddr, dsize, @@ -238,9 +241,9 @@ exec_osf1_imgact(struct image_params *imgp) bail: free(imgp->auxargs, M_TEMP); if (ndp) { - VOP_CLOSE(ndp->ni_vp, FREAD, imgp->proc->p_ucred, - FIRST_THREAD_IN_PROC(imgp->proc)); + VOP_CLOSE(ndp->ni_vp, FREAD, td->td_ucred, td); vrele(ndp->ni_vp); + free(ndp, M_TEMP); } return(error); } |