Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/kern kqueue_register: avoid calling fd_getfile() with fi...
details: https://anonhg.NetBSD.org/src/rev/9906edb11cd3
branches: trunk
changeset: 771271:9906edb11cd3
user: rmind <rmind%NetBSD.org@localhost>
date: Thu Nov 17 22:41:55 2011 +0000
description:
kqueue_register: avoid calling fd_getfile() with filedesc_t::fd_lock held.
Fixes PR/45479 by KOGULE Ryo.
diffstat:
sys/kern/kern_event.c | 9 ++++-----
1 files changed, 4 insertions(+), 5 deletions(-)
diffs (46 lines):
diff -r 9e4a41dc5d1a -r 9906edb11cd3 sys/kern/kern_event.c
--- a/sys/kern/kern_event.c Thu Nov 17 22:09:12 2011 +0000
+++ b/sys/kern/kern_event.c Thu Nov 17 22:41:55 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: kern_event.c,v 1.73 2011/11/17 01:19:37 christos Exp $ */
+/* $NetBSD: kern_event.c,v 1.74 2011/11/17 22:41:55 rmind Exp $ */
/*-
* Copyright (c) 2008, 2009 The NetBSD Foundation, Inc.
@@ -58,7 +58,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_event.c,v 1.73 2011/11/17 01:19:37 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_event.c,v 1.74 2011/11/17 22:41:55 rmind Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -916,18 +916,16 @@
return (EINVAL);
}
- mutex_enter(&fdp->fd_lock);
-
/* search if knote already exists */
if (kfilter->filtops->f_isfd) {
/* monitoring a file descriptor */
fd = kev->ident;
if ((fp = fd_getfile(fd)) == NULL) {
- mutex_exit(&fdp->fd_lock);
rw_exit(&kqueue_filter_lock);
kmem_free(newkn, sizeof(*newkn));
return EBADF;
}
+ mutex_enter(&fdp->fd_lock);
ff = fdp->fd_dt->dt_ff[fd];
if (fd <= fdp->fd_lastkqfile) {
SLIST_FOREACH(kn, &ff->ff_knlist, kn_link) {
@@ -941,6 +939,7 @@
* not monitoring a file descriptor, so
* lookup knotes in internal hash table
*/
+ mutex_enter(&fdp->fd_lock);
if (fdp->fd_knhashmask != 0) {
list = &fdp->fd_knhash[
KN_HASH((u_long)kev->ident, fdp->fd_knhashmask)];
Home |
Main Index |
Thread Index |
Old Index