git: 1e7389419122 - stable/14 - hptmv: Handle errors from copyout() in hpt_set_info()

From: Mark Johnston <markj_at_FreeBSD.org>
Date: Thu, 04 Jan 2024 13:48:02 UTC
The branch stable/14 has been updated by markj:

URL: https://cgit.FreeBSD.org/src/commit/?id=1e73894191229aa896b99348a31cfa93260c08de

commit 1e73894191229aa896b99348a31cfa93260c08de
Author:     Mark Johnston <markj@FreeBSD.org>
AuthorDate: 2023-12-27 00:00:01 +0000
Commit:     Mark Johnston <markj@FreeBSD.org>
CommitDate: 2024-01-04 13:42:13 +0000

    hptmv: Handle errors from copyout() in hpt_set_info()
    
    This is in preparation for annotating copyin() and related functions
    with __result_use_check.
    
    MFC after:      1 week
    
    (cherry picked from commit b4a9e6d81447c46c7bae56dc798097d9d3a4c495)
---
 sys/dev/hptmv/hptproc.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/sys/dev/hptmv/hptproc.c b/sys/dev/hptmv/hptproc.c
index 136b9c59a02a..8f9fffdc5af1 100644
--- a/sys/dev/hptmv/hptproc.c
+++ b/sys/dev/hptmv/hptproc.c
@@ -338,13 +338,13 @@ hpt_set_info(int length)
 			
 			if (err==0) {
 				if (piop->nOutBufferSize)
-					copyout(ke_area + piop->nInBufferSize, (void*)(ULONG_PTR)piop->lpOutBuffer, piop->nOutBufferSize);
+					err = -copyout(ke_area + piop->nInBufferSize, (void*)(ULONG_PTR)piop->lpOutBuffer, piop->nOutBufferSize);
 				
-				if (piop->lpBytesReturned)
-					copyout(&dwRet, (void*)(ULONG_PTR)piop->lpBytesReturned, sizeof(DWORD));
+				if (err == 0 && piop->lpBytesReturned)
+					err = -copyout(&dwRet, (void*)(ULONG_PTR)piop->lpBytesReturned, sizeof(DWORD));
 			
 				free(ke_area, M_DEVBUF);
-				return length;
+				return err == 0 ? length : err;
 			}
 			else  KdPrintW(("Kernel_ioctl(): return %d\n", err));