svn commit: r247736 - in head/sys: kern sys
Pawel Jakub Dawidek
pjd at FreeBSD.org
Sun Mar 3 23:23:36 UTC 2013
Author: pjd
Date: Sun Mar 3 23:23:35 2013
New Revision: 247736
URL: http://svnweb.freebsd.org/changeset/base/247736
Log:
Plug memory leaks in file descriptors passing.
Modified:
head/sys/kern/kern_descrip.c
head/sys/kern/uipc_usrreq.c
head/sys/sys/filedesc.h
Modified: head/sys/kern/kern_descrip.c
==============================================================================
--- head/sys/kern/kern_descrip.c Sun Mar 3 23:07:27 2013 (r247735)
+++ head/sys/kern/kern_descrip.c Sun Mar 3 23:23:35 2013 (r247736)
@@ -1397,7 +1397,7 @@ filecaps_copy(const struct filecaps *src
/*
* Move filecaps structure to the new place and clear the old place.
*/
-static void
+void
filecaps_move(struct filecaps *src, struct filecaps *dst)
{
Modified: head/sys/kern/uipc_usrreq.c
==============================================================================
--- head/sys/kern/uipc_usrreq.c Sun Mar 3 23:07:27 2013 (r247735)
+++ head/sys/kern/uipc_usrreq.c Sun Mar 3 23:23:35 2013 (r247736)
@@ -1686,6 +1686,7 @@ unp_freerights(struct filedescent *fde,
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, st
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;
}
Modified: head/sys/sys/filedesc.h
==============================================================================
--- head/sys/sys/filedesc.h Sun Mar 3 23:07:27 2013 (r247735)
+++ head/sys/sys/filedesc.h Sun Mar 3 23:23:35 2013 (r247736)
@@ -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);
More information about the svn-src-all
mailing list