- Fix leak of struct nlminfo on process exit.
  - Fix malloc type collision, that made the above problem
    difficult to understand.

  Reported by:	Vladimir Sharun <sharun ukr.net>

Approved by:	re (scottl)
This commit is contained in:
glebius 2005-10-27 18:35:19 +00:00
parent 43d272d5d9
commit 42def59c5e
4 changed files with 24 additions and 7 deletions

View File

@ -81,6 +81,9 @@ __FBSDID("$FreeBSD$");
/* Required to be non-static for SysVR4 emulator */
MALLOC_DEFINE(M_ZOMBIE, "zombie", "zombie proc status");
/* Hook for NFS teardown procedure. */
void (*nlminfo_release_p)(struct proc *p);
/*
* exit --
* Death of process.
@ -230,6 +233,12 @@ exit1(struct thread *td, int rv)
mtx_lock(&Giant); /* XXX: not sure if needed */
funsetownlst(&p->p_sigiolst);
/*
* If this process has an nlminfo data area (for lockd), release it
*/
if (nlminfo_release_p != NULL && p->p_nlminfo != NULL)
(*nlminfo_release_p)(p);
/*
* Close open files and release open-file table.
* This may block!

View File

@ -62,9 +62,13 @@ __FBSDID("$FreeBSD$");
#include <nfsclient/nfs_lock.h>
#include <nfsclient/nlminfo.h>
extern void (*nlminfo_release_p)(struct proc *p);
MALLOC_DEFINE(M_NFSLOCK, "NFS lock", "NFS lock request");
MALLOC_DEFINE(M_NLMINFO, "nlminfo", "NFS lock process structure");
static int nfslockdans(struct thread *td, struct lockd_ans *ansp);
static void nlminfo_release(struct proc *p);
/*
* --------------------------------------------------------------------
* A miniature device driver which the userland uses to talk to us.
@ -194,6 +198,7 @@ nfslock_modevent(module_t mod __unused, int type, void *data __unused)
printf("nfslock: pseudo-device\n");
mtx_init(&nfslock_mtx, "nfslock", NULL, MTX_DEF);
TAILQ_INIT(&nfslock_list);
nlminfo_release_p = nlminfo_release;
nfslock_dev = make_dev(&nfslock_cdevsw, 0,
UID_ROOT, GID_KMEM, 0600, _PATH_NFSLCKDEV);
return (0);
@ -259,7 +264,7 @@ nfs_dolock(struct vop_advlock_args *ap)
*/
if (p->p_nlminfo == NULL) {
MALLOC(p->p_nlminfo, struct nlminfo *,
sizeof(struct nlminfo), M_LOCKF, M_WAITOK | M_ZERO);
sizeof(struct nlminfo), M_NLMINFO, M_WAITOK | M_ZERO);
p->p_nlminfo->pid_start = p->p_stats->p_start;
timevaladd(&p->p_nlminfo->pid_start, &boottime);
}
@ -381,3 +386,12 @@ nfslockdans(struct thread *td, struct lockd_ans *ansp)
return (0);
}
/*
* Free nlminfo attached to process.
*/
void
nlminfo_release(struct proc *p)
{
free(p->p_nlminfo, M_NLMINFO);
p->p_nlminfo = NULL;
}

View File

@ -40,5 +40,3 @@ struct nlminfo {
int getlk_pid;
struct timeval pid_start; /* process starting time */
};
extern void nlminfo_release(struct proc *p);

View File

@ -40,10 +40,6 @@
struct vop_advlock_args;
#ifdef MALLOC_DECLARE
MALLOC_DECLARE(M_LOCKF);
#endif
/*
* The lockf structure is a kernel structure which contains the information
* associated with a byte range lock. The lockf structures are linked into