CVS commit: src/sys/dev/acpi/wmi

2023-08-11 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Fri Aug 11 08:36:59 UTC 2023

Modified Files:
src/sys/dev/acpi/wmi: wmi_acpi.c

Log Message:
acpiwmi(4): Fix abuse of char buffer for struct guid_t content.

Nothing guarantees alignment, so this is all undefined behaviour,
even if we don't touch the uninitialized members.

XXX pullup-10
XXX pullup-9
XXX pullup-8


To generate a diff of this commit:
cvs rdiff -u -r1.22 -r1.23 src/sys/dev/acpi/wmi/wmi_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/wmi/wmi_acpi.c
diff -u src/sys/dev/acpi/wmi/wmi_acpi.c:1.22 src/sys/dev/acpi/wmi/wmi_acpi.c:1.23
--- src/sys/dev/acpi/wmi/wmi_acpi.c:1.22	Thu Aug 10 20:49:19 2023
+++ src/sys/dev/acpi/wmi/wmi_acpi.c	Fri Aug 11 08:36:59 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: wmi_acpi.c,v 1.22 2023/08/10 20:49:19 mrg Exp $	*/
+/*	$NetBSD: wmi_acpi.c,v 1.23 2023/08/11 08:36:59 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2009, 2010 Jukka Ruohonen 
@@ -27,7 +27,7 @@
  * SUCH DAMAGE.
  */
 #include 
-__KERNEL_RCSID(0, "$NetBSD: wmi_acpi.c,v 1.22 2023/08/10 20:49:19 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: wmi_acpi.c,v 1.23 2023/08/11 08:36:59 riastradh Exp $");
 
 #include 
 #include 
@@ -320,8 +320,8 @@ acpi_wmi_guid_get(struct acpi_wmi_softc 
 const char *src, struct wmi_t **out)
 {
 	struct wmi_t *wmi;
-	struct guid_t *guid;
-	char bin[MAX(16, sizeof(*guid))];
+	struct guid_t guid;
+	char bin[16];
 	char hex[3];
 	const char *ptr;
 	uint8_t i;
@@ -346,14 +346,14 @@ acpi_wmi_guid_get(struct acpi_wmi_softc 
 		ptr++;
 	}
 
-	guid = (struct guid_t *)bin;
-	guid->data1 = be32toh(guid->data1);
-	guid->data2 = be16toh(guid->data2);
-	guid->data3 = be16toh(guid->data3);
+	guid.data1 = be32dec([0]);
+	guid.data2 = be16dec([4]);
+	guid.data3 = be16dec([6]);
+	memcpy(guid.data4, [8], 8);
 
 	SIMPLEQ_FOREACH(wmi, >wmi_head, wmi_link) {
 
-		if (GUIDCMP(guid, >guid) != 0) {
+		if (GUIDCMP(, >guid) != 0) {
 
 			if (out != NULL)
 *out = wmi;



CVS commit: src/sys/dev/acpi/wmi

2023-08-11 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Fri Aug 11 08:36:59 UTC 2023

Modified Files:
src/sys/dev/acpi/wmi: wmi_acpi.c

Log Message:
acpiwmi(4): Fix abuse of char buffer for struct guid_t content.

Nothing guarantees alignment, so this is all undefined behaviour,
even if we don't touch the uninitialized members.

XXX pullup-10
XXX pullup-9
XXX pullup-8


To generate a diff of this commit:
cvs rdiff -u -r1.22 -r1.23 src/sys/dev/acpi/wmi/wmi_acpi.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/dev/acpi/wmi

2023-05-09 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Wed May 10 00:08:23 UTC 2023

Modified Files:
src/sys/dev/acpi/wmi: wmi_acpi.c

Log Message:
acpiwmi(4): Use config_detach_children.


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 src/sys/dev/acpi/wmi/wmi_acpi.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/dev/acpi/wmi

2023-05-09 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Wed May 10 00:08:23 UTC 2023

Modified Files:
src/sys/dev/acpi/wmi: wmi_acpi.c

Log Message:
acpiwmi(4): Use config_detach_children.


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 src/sys/dev/acpi/wmi/wmi_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/wmi/wmi_acpi.c
diff -u src/sys/dev/acpi/wmi/wmi_acpi.c:1.20 src/sys/dev/acpi/wmi/wmi_acpi.c:1.21
--- src/sys/dev/acpi/wmi/wmi_acpi.c:1.20	Sun Dec 12 22:20:52 2021
+++ src/sys/dev/acpi/wmi/wmi_acpi.c	Wed May 10 00:08:22 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: wmi_acpi.c,v 1.20 2021/12/12 22:20:52 andvar Exp $	*/
+/*	$NetBSD: wmi_acpi.c,v 1.21 2023/05/10 00:08:22 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2009, 2010 Jukka Ruohonen 
@@ -27,7 +27,7 @@
  * SUCH DAMAGE.
  */
 #include 
-__KERNEL_RCSID(0, "$NetBSD: wmi_acpi.c,v 1.20 2021/12/12 22:20:52 andvar Exp $");
+__KERNEL_RCSID(0, "$NetBSD: wmi_acpi.c,v 1.21 2023/05/10 00:08:22 riastradh Exp $");
 
 #include 
 #include 
@@ -126,18 +126,19 @@ static int
 acpi_wmi_detach(device_t self, int flags)
 {
 	struct acpi_wmi_softc *sc = device_private(self);
+	int error;
+
+	error = config_detach_children(self, flags);
+	if (error)
+		return error;
 
 	acpi_wmi_event_del(sc);
 
 	if (sc->sc_ecdev != NULL) {
-
 		(void)AcpiRemoveAddressSpaceHandler(sc->sc_node->ad_handle,
 		ACPI_ADR_SPACE_EC, acpi_wmi_ec_handler);
 	}
 
-	if (sc->sc_child != NULL)
-		(void)config_detach(sc->sc_child, flags);
-
 	acpi_wmi_del(sc);
 	pmf_device_deregister(self);
 



Re: CVS commit: src/sys/dev/acpi/wmi

2017-12-03 Thread David Holland
On Sun, Dec 03, 2017 at 11:53:37PM +0100, Manuel Bouyer wrote:
 > On Sun, Dec 03, 2017 at 11:06:47AM -0800, bch wrote:
 > > ...
 > > /usr/src/sys/dev/acpi/wmi/wmi_dell.c: In function 'wmi_dell_action':
 > > /usr/src/sys/dev/acpi/wmi/wmi_dell.c:234:16: error: comparison between
 > > signed and unsigned integer expressions [-Werror=sign-compare]
 > >   for (i = 0; i < __arraycount(wmi_dell_actions); i++) {
 > > ^
 > > cc1: all warnings being treated as errors
 > 
 > that's strange, I don't get it on my sources tree.

Odd that you wouldn't, but maybe it depends on whether you're building
a kernel or something rumpity.

 > Would changing i to unsigned int fix the warning ?

Yes. Provided of course that it doesn't break elsewhere that way :-)

-- 
David A. Holland
dholl...@netbsd.org


Re: CVS commit: src/sys/dev/acpi/wmi

2017-12-03 Thread Manuel Bouyer
On Sun, Dec 03, 2017 at 11:06:47AM -0800, bch wrote:
> ...
> /usr/src/sys/dev/acpi/wmi/wmi_dell.c: In function 'wmi_dell_action':
> /usr/src/sys/dev/acpi/wmi/wmi_dell.c:234:16: error: comparison between
> signed and unsigned integer expressions [-Werror=sign-compare]
>   for (i = 0; i < __arraycount(wmi_dell_actions); i++) {
> ^
> cc1: all warnings being treated as errors

that's strange, I don't get it on my sources tree.
Would changing i to unsigned int fix the warning ?

-- 
Manuel Bouyer 
 NetBSD: 26 ans d'experience feront toujours la difference
--


Re: CVS commit: src/sys/dev/acpi/wmi

2017-12-03 Thread bch
...
/usr/src/sys/dev/acpi/wmi/wmi_dell.c: In function 'wmi_dell_action':
/usr/src/sys/dev/acpi/wmi/wmi_dell.c:234:16: error: comparison between
signed and unsigned integer expressions [-Werror=sign-compare]
  for (i = 0; i < __arraycount(wmi_dell_actions); i++) {
^
cc1: all warnings being treated as errors




On 12/3/17, Manuel Bouyer  wrote:
> Module Name:  src
> Committed By: bouyer
> Date: Sun Dec  3 17:40:48 UTC 2017
>
> Modified Files:
>   src/sys/dev/acpi/wmi: wmi_dell.c
>
> Log Message:
> Fix dell WMI mappings:
> - query the descriptor to get the interface version, needed to workaround
>   a bug in the BIOS/ACPI
> - properly decode the event buffer in type/subtype, and handle multiple
> events
>   per handler call
> - record some known type/subtype in a table, with associated actions.
>
> Informations mostly from linux. Tested on a Dell 5480 laptop.
>
>
> To generate a diff of this commit:
> cvs rdiff -u -r1.9 -r1.10 src/sys/dev/acpi/wmi/wmi_dell.c
>
> Please note that diffs are not public domain; they are subject to the
> copyright notices on the relevant files.
>
>