Module Name:    src
Committed By:   christos
Date:           Mon Feb  1 16:32:28 UTC 2016

Modified Files:
        src/sys/net: bpf.c

Log Message:
Do less work under the kernel lock, otherwise dhcpcd aborting causes us
to deadlock.


To generate a diff of this commit:
cvs rdiff -u -r1.193 -r1.194 src/sys/net/bpf.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/net/bpf.c
diff -u src/sys/net/bpf.c:1.193 src/sys/net/bpf.c:1.194
--- src/sys/net/bpf.c:1.193	Wed Dec 16 18:14:42 2015
+++ src/sys/net/bpf.c	Mon Feb  1 11:32:28 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: bpf.c,v 1.193 2015/12/16 23:14:42 christos Exp $	*/
+/*	$NetBSD: bpf.c,v 1.194 2016/02/01 16:32:28 christos Exp $	*/
 
 /*
  * Copyright (c) 1990, 1991, 1993
@@ -39,7 +39,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: bpf.c,v 1.193 2015/12/16 23:14:42 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bpf.c,v 1.194 2016/02/01 16:32:28 christos Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_bpf.h"
@@ -475,12 +475,18 @@ bpfopen(dev_t dev, int flag, int mode, s
 static int
 bpf_close(struct file *fp)
 {
-	struct bpf_d *d = fp->f_bpf;
+	struct bpf_d *d;
 	int s;
 
 	KERNEL_LOCK(1, NULL);
 	mutex_enter(&bpf_mtx);
 
+	if ((d = fp->f_bpf) == NULL) {
+		mutex_exit(&bpf_mtx);
+		KERNEL_UNLOCK_ONE(NULL);
+		return 0;
+	}
+
 	/*
 	 * Refresh the PID associated with this bpf file.
 	 */
@@ -495,15 +501,16 @@ bpf_close(struct file *fp)
 	splx(s);
 	bpf_freed(d);
 	LIST_REMOVE(d, bd_list);
-	callout_destroy(&d->bd_callout);
-	seldestroy(&d->bd_sel);
-	softint_disestablish(d->bd_sih);
-	free(d, M_DEVBUF);
 	fp->f_bpf = NULL;
 
 	mutex_exit(&bpf_mtx);
 	KERNEL_UNLOCK_ONE(NULL);
 
+	callout_destroy(&d->bd_callout);
+	seldestroy(&d->bd_sel);
+	softint_disestablish(d->bd_sih);
+	free(d, M_DEVBUF);
+
 	return (0);
 }
 

Reply via email to