Module Name:    src
Committed By:   msaitoh
Date:           Mon Aug  5 10:09:35 UTC 2019

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

Log Message:
 Fix undefined behavior in thinkpad_mask_init(). Found by kUBSan.


To generate a diff of this commit:
cvs rdiff -u -r1.46 -r1.47 src/sys/dev/acpi/thinkpad_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/thinkpad_acpi.c
diff -u src/sys/dev/acpi/thinkpad_acpi.c:1.46 src/sys/dev/acpi/thinkpad_acpi.c:1.47
--- src/sys/dev/acpi/thinkpad_acpi.c:1.46	Sun Apr  3 10:36:00 2016
+++ src/sys/dev/acpi/thinkpad_acpi.c	Mon Aug  5 10:09:35 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: thinkpad_acpi.c,v 1.46 2016/04/03 10:36:00 mlelstv Exp $ */
+/* $NetBSD: thinkpad_acpi.c,v 1.47 2019/08/05 10:09:35 msaitoh Exp $ */
 
 /*-
  * Copyright (c) 2007 Jared D. McNeill <jmcne...@invisible.ca>
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: thinkpad_acpi.c,v 1.46 2016/04/03 10:36:00 mlelstv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: thinkpad_acpi.c,v 1.47 2019/08/05 10:09:35 msaitoh Exp $");
 
 #include <sys/param.h>
 #include <sys/device.h>
@@ -565,7 +565,7 @@ thinkpad_mask_init(thinkpad_softc_t *sc,
 
 	for (i = 0; i < 32; i++) {
 		param[0].Integer.Value = i + 1;
-		param[1].Integer.Value = (((1 << i) & mask) != 0);
+		param[1].Integer.Value = ((__BIT(i) & mask) != 0);
 
 		rv = AcpiEvaluateObject(sc->sc_node->ad_handle, "MHKM",
 		    &params, NULL);

Reply via email to