Module Name: src
Committed By: knakahara
Date: Fri Jul 24 06:49:58 UTC 2015
Modified Files:
src/sys/arch/x86/pci: pci_intr_machdep.c
Log Message:
fix pci_intr_alloc(..., NULL, 0). reported [email protected]
To generate a diff of this commit:
cvs rdiff -u -r1.34 -r1.35 src/sys/arch/x86/pci/pci_intr_machdep.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/pci/pci_intr_machdep.c
diff -u src/sys/arch/x86/pci/pci_intr_machdep.c:1.34 src/sys/arch/x86/pci/pci_intr_machdep.c:1.35
--- src/sys/arch/x86/pci/pci_intr_machdep.c:1.34 Tue Jul 21 03:10:42 2015
+++ src/sys/arch/x86/pci/pci_intr_machdep.c Fri Jul 24 06:49:58 2015
@@ -1,4 +1,4 @@
-/* $NetBSD: pci_intr_machdep.c,v 1.34 2015/07/21 03:10:42 knakahara Exp $ */
+/* $NetBSD: pci_intr_machdep.c,v 1.35 2015/07/24 06:49:58 knakahara Exp $ */
/*-
* Copyright (c) 1997, 1998, 2009 The NetBSD Foundation, Inc.
@@ -73,7 +73,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pci_intr_machdep.c,v 1.34 2015/07/21 03:10:42 knakahara Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pci_intr_machdep.c,v 1.35 2015/07/24 06:49:58 knakahara Exp $");
#include <sys/types.h>
#include <sys/param.h>
@@ -484,7 +484,8 @@ pci_intr_alloc(const struct pci_attach_a
}
}
- memset(counts, 0, sizeof(counts[0]) * PCI_INTR_TYPE_SIZE);
+ if (counts != NULL)
+ memset(counts, 0, sizeof(counts[0]) * PCI_INTR_TYPE_SIZE);
error = EINVAL;
/* try MSI-X */
@@ -493,6 +494,8 @@ pci_intr_alloc(const struct pci_attach_a
if (msix_count > 0) {
error = pci_msix_alloc_exact(pa, ihps, msix_count);
if (error == 0) {
+ KASSERTMSG(counts != NULL,
+ "If MSI-X is used, counts must not be NULL.");
counts[PCI_INTR_TYPE_MSIX] = msix_count;
goto out;
}
@@ -504,10 +507,9 @@ pci_intr_alloc(const struct pci_attach_a
if (msi_count > 0) {
error = pci_msi_alloc_exact(pa, ihps, msi_count);
if (error == 0) {
- if (counts != NULL) {
+ if (counts != NULL)
counts[PCI_INTR_TYPE_MSI] = msi_count;
- goto out;
- }
+ goto out;
}
}