Module Name:    src
Committed By:   knakahara
Date:           Mon Mar 26 02:30:08 UTC 2018

Modified Files:
        src/sys/arch/x86/x86: intr.c

Log Message:
Fix "intrctl list" causes panic while attaching MSI/MSI-X devices.

When there are devices which is already pci_intr_alloc'ed, however is not
established yet, "intrctl list" causes panic. E.g.
    # while true; do intrctl list > /dev/null ; done&
    # drvctl -d ixg0 && drvctl -r pci0

And add some KASSERTMSG to similar but not the same code.

Pointed out by msaitoh@n.o.

XXX pullup-8


To generate a diff of this commit:
cvs rdiff -u -r1.123 -r1.124 src/sys/arch/x86/x86/intr.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/arch/x86/x86/intr.c
diff -u src/sys/arch/x86/x86/intr.c:1.123 src/sys/arch/x86/x86/intr.c:1.124
--- src/sys/arch/x86/x86/intr.c:1.123	Sat Feb 17 18:51:53 2018
+++ src/sys/arch/x86/x86/intr.c	Mon Mar 26 02:30:08 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: intr.c,v 1.123 2018/02/17 18:51:53 maxv Exp $	*/
+/*	$NetBSD: intr.c,v 1.124 2018/03/26 02:30:08 knakahara Exp $	*/
 
 /*
  * Copyright (c) 2007, 2008, 2009 The NetBSD Foundation, Inc.
@@ -133,7 +133,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: intr.c,v 1.123 2018/02/17 18:51:53 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: intr.c,v 1.124 2018/03/26 02:30:08 knakahara Exp $");
 
 #include "opt_intrdebug.h"
 #include "opt_multiprocessor.h"
@@ -2012,6 +2012,9 @@ intr_get_affinity(struct intrsource *isp
 		return;
 	}
 
+	KASSERTMSG(isp->is_handlers != NULL,
+	    "Don't get affinity for the device which is not established.");
+
 	ci = isp->is_handlers->ih_cpu;
 	if (ci == NULL) {
 		kcpuset_zero(cpuset);
@@ -2064,6 +2067,9 @@ intr_set_affinity(struct intrsource *isp
 	}
 
 	ih = isp->is_handlers;
+	KASSERTMSG(ih != NULL,
+	    "Don't set affinity for the device which is not established.");
+
 	oldci = ih->ih_cpu;
 	if (newci == oldci) /* nothing to do */
 		return 0;
@@ -2130,6 +2136,13 @@ intr_is_affinity_intrsource(struct intrs
 
 	KASSERT(mutex_owned(&cpu_lock));
 
+	/*
+	 * The device is already pci_intr_alloc'ed, however it is not
+	 * established yet.
+	 */
+	if (isp->is_handlers == NULL)
+		return false;
+
 	ci = isp->is_handlers->ih_cpu;
 	KASSERT(ci != NULL);
 

Reply via email to