Module Name: src Committed By: pgoyette Date: Sat Nov 21 07:45:30 UTC 2015
Modified Files: src/sys/dev/filemon: filemon.c Log Message: If a second call to the SET_FD ioctl occurs, release the reference we hold on the earlier outout file. To generate a diff of this commit: cvs rdiff -u -r1.16 -r1.17 src/sys/dev/filemon/filemon.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/dev/filemon/filemon.c diff -u src/sys/dev/filemon/filemon.c:1.16 src/sys/dev/filemon/filemon.c:1.17 --- src/sys/dev/filemon/filemon.c:1.16 Sat Nov 21 03:34:28 2015 +++ src/sys/dev/filemon/filemon.c Sat Nov 21 07:45:30 2015 @@ -24,7 +24,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: filemon.c,v 1.16 2015/11/21 03:34:28 pgoyette Exp $"); +__KERNEL_RCSID(0, "$NetBSD: filemon.c,v 1.17 2015/11/21 07:45:30 pgoyette Exp $"); #include <sys/param.h> #include <sys/kernel.h> @@ -294,6 +294,12 @@ filemon_ioctl(struct file * fp, u_long c switch (cmd) { case FILEMON_SET_FD: /* Set the output file descriptor. */ + + /* First, release any current output file descriptor */ + if (filemon->fm_fp) + fd_putfile(filemon->fm_fd); + + /* Now set up the new one */ filemon->fm_fd = *((int *) data); if ((filemon->fm_fp = fd_getfile(filemon->fm_fd)) == NULL) { rw_exit(&filemon->fm_mtx);