- 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>
This commit is contained in:
parent
d7f119abd5
commit
c0bc2867c1
@ -82,6 +82,9 @@ __FBSDID("$FreeBSD$");
|
|||||||
/* Required to be non-static for SysVR4 emulator */
|
/* Required to be non-static for SysVR4 emulator */
|
||||||
MALLOC_DEFINE(M_ZOMBIE, "zombie", "zombie proc status");
|
MALLOC_DEFINE(M_ZOMBIE, "zombie", "zombie proc status");
|
||||||
|
|
||||||
|
/* Hook for NFS teardown procedure. */
|
||||||
|
void (*nlminfo_release_p)(struct proc *p);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* exit --
|
* exit --
|
||||||
* Death of process.
|
* Death of process.
|
||||||
@ -233,6 +236,12 @@ retry:
|
|||||||
mtx_lock(&Giant); /* XXX: not sure if needed */
|
mtx_lock(&Giant); /* XXX: not sure if needed */
|
||||||
funsetownlst(&p->p_sigiolst);
|
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.
|
* Close open files and release open-file table.
|
||||||
* This may block!
|
* This may block!
|
||||||
|
@ -62,9 +62,13 @@ __FBSDID("$FreeBSD$");
|
|||||||
#include <nfsclient/nfs_lock.h>
|
#include <nfsclient/nfs_lock.h>
|
||||||
#include <nfsclient/nlminfo.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_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 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.
|
* 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");
|
printf("nfslock: pseudo-device\n");
|
||||||
mtx_init(&nfslock_mtx, "nfslock", NULL, MTX_DEF);
|
mtx_init(&nfslock_mtx, "nfslock", NULL, MTX_DEF);
|
||||||
TAILQ_INIT(&nfslock_list);
|
TAILQ_INIT(&nfslock_list);
|
||||||
|
nlminfo_release_p = nlminfo_release;
|
||||||
nfslock_dev = make_dev(&nfslock_cdevsw, 0,
|
nfslock_dev = make_dev(&nfslock_cdevsw, 0,
|
||||||
UID_ROOT, GID_KMEM, 0600, _PATH_NFSLCKDEV);
|
UID_ROOT, GID_KMEM, 0600, _PATH_NFSLCKDEV);
|
||||||
return (0);
|
return (0);
|
||||||
@ -259,7 +264,7 @@ nfs_dolock(struct vop_advlock_args *ap)
|
|||||||
*/
|
*/
|
||||||
if (p->p_nlminfo == NULL) {
|
if (p->p_nlminfo == NULL) {
|
||||||
MALLOC(p->p_nlminfo, struct nlminfo *,
|
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;
|
p->p_nlminfo->pid_start = p->p_stats->p_start;
|
||||||
timevaladd(&p->p_nlminfo->pid_start, &boottime);
|
timevaladd(&p->p_nlminfo->pid_start, &boottime);
|
||||||
}
|
}
|
||||||
@ -381,3 +386,12 @@ nfslockdans(struct thread *td, struct lockd_ans *ansp)
|
|||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Free nlminfo attached to process.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
nlminfo_release(struct proc *p)
|
||||||
|
{
|
||||||
|
free(p->p_nlminfo, M_NLMINFO);
|
||||||
|
p->p_nlminfo = NULL;
|
||||||
|
}
|
||||||
|
@ -40,5 +40,3 @@ struct nlminfo {
|
|||||||
int getlk_pid;
|
int getlk_pid;
|
||||||
struct timeval pid_start; /* process starting time */
|
struct timeval pid_start; /* process starting time */
|
||||||
};
|
};
|
||||||
|
|
||||||
extern void nlminfo_release(struct proc *p);
|
|
||||||
|
@ -40,10 +40,6 @@
|
|||||||
|
|
||||||
struct vop_advlock_args;
|
struct vop_advlock_args;
|
||||||
|
|
||||||
#ifdef MALLOC_DECLARE
|
|
||||||
MALLOC_DECLARE(M_LOCKF);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The lockf structure is a kernel structure which contains the information
|
* The lockf structure is a kernel structure which contains the information
|
||||||
* associated with a byte range lock. The lockf structures are linked into
|
* associated with a byte range lock. The lockf structures are linked into
|
||||||
|
Loading…
x
Reference in New Issue
Block a user