diff options
author | pjd <pjd@FreeBSD.org> | 2013-03-03 23:23:35 +0000 |
---|---|---|
committer | pjd <pjd@FreeBSD.org> | 2013-03-03 23:23:35 +0000 |
commit | 1df614f5db4cff750015f3ddbe56c83f7ed799d4 (patch) | |
tree | 814f4da567b0c4d523fec3a931d724cc0def9246 | |
parent | 2b4e636b244795c1b6f7fd8c71009d903a03fd40 (diff) | |
download | FreeBSD-src-1df614f5db4cff750015f3ddbe56c83f7ed799d4.zip FreeBSD-src-1df614f5db4cff750015f3ddbe56c83f7ed799d4.tar.gz |
Plug memory leaks in file descriptors passing.
-rw-r--r-- | sys/kern/kern_descrip.c | 2 | ||||
-rw-r--r-- | sys/kern/uipc_usrreq.c | 3 | ||||
-rw-r--r-- | sys/sys/filedesc.h | 1 |
3 files changed, 4 insertions, 2 deletions
diff --git a/sys/kern/kern_descrip.c b/sys/kern/kern_descrip.c index b146bab..704f0f3 100644 --- a/sys/kern/kern_descrip.c +++ b/sys/kern/kern_descrip.c @@ -1397,7 +1397,7 @@ filecaps_copy(const struct filecaps *src, struct filecaps *dst) /* * Move filecaps structure to the new place and clear the old place. */ -static void +void filecaps_move(struct filecaps *src, struct filecaps *dst) { diff --git a/sys/kern/uipc_usrreq.c b/sys/kern/uipc_usrreq.c index 1da80e0..e36cffd 100644 --- a/sys/kern/uipc_usrreq.c +++ b/sys/kern/uipc_usrreq.c @@ -1686,6 +1686,7 @@ unp_freerights(struct filedescent *fde, int fdcount) for (i = 0; i < fdcount; i++, fde++) { fp = fde->fde_file; + filecaps_free(&fdep->fde_caps); bzero(fde, sizeof(*fde)); unp_discard(fp); } @@ -1760,7 +1761,7 @@ unp_externalize(struct mbuf *control, struct mbuf **controlp) panic("unp_externalize fdalloc failed"); fde = &fdesc->fd_ofiles[f]; fde->fde_file = fdep->fde_file; - filecaps_copy(&fdep->fde_caps, &fde->fde_caps); + filecaps_move(&fdep->fde_caps, &fde->fde_caps); unp_externalize_fp(fde->fde_file); *fdp = f; } diff --git a/sys/sys/filedesc.h b/sys/sys/filedesc.h index f3e3a09..d9fe0e0 100644 --- a/sys/sys/filedesc.h +++ b/sys/sys/filedesc.h @@ -136,6 +136,7 @@ struct thread; void filecaps_init(struct filecaps *fcaps); void filecaps_copy(const struct filecaps *src, struct filecaps *dst); +void filecaps_move(struct filecaps *src, struct filecaps *dst); void filecaps_free(struct filecaps *fcaps); int closef(struct file *fp, struct thread *td); |