Module Name:    src
Committed By:   jruoho
Date:           Fri Apr 23 15:20:35 UTC 2010

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

Log Message:
When setting the power, always mark the state as invalid on failure, even if
going to D0. Also fix a potential NULL pointer dereference in an aprint_().


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/dev/acpi/acpi_power.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/acpi_power.c
diff -u src/sys/dev/acpi/acpi_power.c:1.1 src/sys/dev/acpi/acpi_power.c:1.2
--- src/sys/dev/acpi/acpi_power.c:1.1	Thu Apr 22 18:40:09 2010
+++ src/sys/dev/acpi/acpi_power.c	Fri Apr 23 15:20:35 2010
@@ -1,4 +1,4 @@
-/* $NetBSD: acpi_power.c,v 1.1 2010/04/22 18:40:09 jruoho Exp $ */
+/* $NetBSD: acpi_power.c,v 1.2 2010/04/23 15:20:35 jruoho Exp $ */
 
 /*-
  * Copyright (c) 2009, 2010 The NetBSD Foundation, Inc.
@@ -56,7 +56,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: acpi_power.c,v 1.1 2010/04/22 18:40:09 jruoho Exp $");
+__KERNEL_RCSID(0, "$NetBSD: acpi_power.c,v 1.2 2010/04/23 15:20:35 jruoho Exp $");
 
 #include <sys/param.h>
 #include <sys/kmem.h>
@@ -423,21 +423,12 @@
 	return true;
 
 fail:
-	/*
-	 * It is never an error to go to D0.
-	 */
-	if (state != ACPI_STATE_D0) {
-
-		aprint_error_dev(ad->ad_root,
-		    "failed to set power state to D%d for %s: %s\n",
-		    state, ad->ad_name, AcpiFormatException(rv));
+	ad->ad_state = ACPI_STATE_ERROR;
 
-		ad->ad_state = ACPI_STATE_ERROR;
+	aprint_error_dev(ad->ad_root, "failed to set power state to D%d "
+	    "for %s: %s\n", state, ad->ad_name, AcpiFormatException(rv));
 
-		return false;
-	}
-
-	return true;
+	return false;
 }
 
 /*
@@ -459,7 +450,7 @@
 	}
 
 	aprint_error_dev(sc->sc_dev, "%s: failed to "
-	    "find node %s\n", __func__, ad->ad_name);
+	    "find node %s\n", __func__, acpi_xname(hdl));
 
 	return false;
 }

Reply via email to