Module Name:    src
Committed By:   cegger
Date:           Tue Aug 18 21:33:29 UTC 2009

Modified Files:
        src/sys/dev/acpi: wss_acpi.c

Log Message:
with new ACPICA, idstr may be NULL.
Check against NULL, this fixes a crash on my HP Pavilion dv9700 Laptop.
While here simplify the loop via __arraycount()


To generate a diff of this commit:
cvs rdiff -u -r1.24 -r1.25 src/sys/dev/acpi/wss_acpi.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/acpi/wss_acpi.c
diff -u src/sys/dev/acpi/wss_acpi.c:1.24 src/sys/dev/acpi/wss_acpi.c:1.25
--- src/sys/dev/acpi/wss_acpi.c:1.24	Tue Aug 18 16:41:02 2009
+++ src/sys/dev/acpi/wss_acpi.c	Tue Aug 18 21:33:29 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: wss_acpi.c,v 1.24 2009/08/18 16:41:02 jmcneill Exp $ */
+/* $NetBSD: wss_acpi.c,v 1.25 2009/08/18 21:33:29 cegger Exp $ */
 
 /*
  * Copyright (c) 2002 Jared D. McNeill <[email protected]>
@@ -26,7 +26,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: wss_acpi.c,v 1.24 2009/08/18 16:41:02 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: wss_acpi.c,v 1.25 2009/08/18 21:33:29 cegger Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -73,7 +73,6 @@
 	{ "NMX2210", 1, 2, WSS_CODEC },
 	{ "CSC0000", 0, 1, 0 },		/* Dell Latitude CPi */
 	{ "CSC0100", 0, 1, 0 },		/* CS4610 with CS4236 codec */
-	{ { 0 }, 0, 0, 0 }
 };
 
 static int wss_acpi_hints_index (const char *);
@@ -81,9 +80,11 @@
 static int
 wss_acpi_hints_index(const char *idstr)
 {
-	int idx = 0;
+	int idx;
 
-	while (wss_acpi_hints[idx].idstr[0] != 0) {
+	if (idstr == NULL)
+		return -1;
+	for (idx = 0; idx < __arraycount(wss_acpi_hints); idx++) {
 		if (!strcmp(wss_acpi_hints[idx].idstr, idstr))
 			return idx;
 		++idx;

Reply via email to