Plug memory leaks in file descriptors passing.

This commit is contained in:
Pawel Jakub Dawidek 2013-03-03 23:23:35 +00:00
parent 4a99f3fcc1
commit a6157c3d61
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=247736
3 changed files with 4 additions and 2 deletions

View File

@ -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)
{

View File

@ -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;
}

View File

@ -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);