git: d0d5a75f66a4 - main - sysutils/acpi_call: Check for errors from copyout()

From: Mark Johnston <markj_at_FreeBSD.org>
Date: Wed, 03 Jan 2024 21:54:24 UTC
The branch main has been updated by markj:

URL: https://cgit.FreeBSD.org/ports/commit/?id=d0d5a75f66a400f72b5206debdf60ca5fa05da53

commit d0d5a75f66a400f72b5206debdf60ca5fa05da53
Author:     Mark Johnston <markj@FreeBSD.org>
AuthorDate: 2024-01-02 18:18:53 +0000
Commit:     Mark Johnston <markj@FreeBSD.org>
CommitDate: 2024-01-03 21:53:33 +0000

    sysutils/acpi_call: Check for errors from copyout()
    
    The base system will soon require all copyout() calls to either preserve
    the return value or explicitly ignore it.
    
    PR:             275986
    Approved by:    antoine
---
 sysutils/acpi_call/Makefile                 |  2 +-
 sysutils/acpi_call/files/patch-acpi__call.c | 12 ++++++++----
 2 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/sysutils/acpi_call/Makefile b/sysutils/acpi_call/Makefile
index b56ff57106a8..0b2b810542a9 100644
--- a/sysutils/acpi_call/Makefile
+++ b/sysutils/acpi_call/Makefile
@@ -1,6 +1,6 @@
 PORTNAME=	acpi_call
 PORTVERSION=	1.0.1
-PORTREVISION=	1
+PORTREVISION=	2
 CATEGORIES=	sysutils
 MASTER_SITES=	http://projects.ukrweb.net/files/ \
 		http://imax.in.ua/files/
diff --git a/sysutils/acpi_call/files/patch-acpi__call.c b/sysutils/acpi_call/files/patch-acpi__call.c
index 39d1785bae2d..a278233a969e 100644
--- a/sysutils/acpi_call/files/patch-acpi__call.c
+++ b/sysutils/acpi_call/files/patch-acpi__call.c
@@ -12,7 +12,7 @@
  #include <sys/kernel.h>
  #if __FreeBSD__ >= 8
  #	include <contrib/dev/acpica/include/acpi.h>
-@@ -45,18 +45,97 @@
+@@ -45,18 +45,99 @@ void acpi_call_fixup_pointers(ACPI_OBJECT *p, UINT8 *o
  
  void acpi_call_fixup_pointers(ACPI_OBJECT *p, UINT8 *orig);
  
@@ -95,7 +95,9 @@
 +	ACPI_OBJECT_LIST	*args;
  	ACPI_BUFFER	result;
 +	char		path[256];
++	int		error;
  
++	error = 0;
  	result.Length = ACPI_ALLOCATE_BUFFER;
  	result.Pointer = NULL;
  
@@ -111,13 +113,14 @@
  		if (ACPI_SUCCESS(params->retval))
  		{
  			if (result.Pointer != NULL)
-@@ -64,30 +143,31 @@ acpi_call_ioctl(u_long cmd, caddr_t addr, void *arg)
+@@ -64,30 +145,31 @@ acpi_call_ioctl(u_long cmd, caddr_t addr, void *arg)
  				if (params->result.Pointer != NULL)
  				{	
  					params->result.Length = min(params->result.Length, result.Length);
+-					copyout(result.Pointer, params->result.Pointer,
 +					if (result.Length >= sizeof(ACPI_OBJECT))
 +						acpi_call_fixup_pointers((ACPI_OBJECT*)result.Pointer, params->result.Pointer);
- 					copyout(result.Pointer, params->result.Pointer,
++					error = copyout(result.Pointer, params->result.Pointer,
  							params->result.Length);
  					params->reslen = result.Length;
 -					if (result.Length >= sizeof(ACPI_OBJECT))
@@ -129,7 +132,8 @@
 +		free_acpi_object_list(args);
  	}
  
- 	return (0);
+-	return (0);
++	return error;
  }
  
  void