Plug memory leaks in file descriptors passing.
This commit is contained in:
parent
4a99f3fcc1
commit
a6157c3d61
@ -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)
|
||||
{
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user