git: 76ecdbce7703 - stable/13 - powerpc: Avoid ignoring copyin()'s return value

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

URL: https://cgit.FreeBSD.org/src/commit/?id=76ecdbce7703d5a7bae90d53cb612a496c87c261

commit 76ecdbce7703d5a7bae90d53cb612a496c87c261
Author:     Mark Johnston <markj@FreeBSD.org>
AuthorDate: 2023-12-26 01:40:16 +0000
Commit:     Mark Johnston <markj@FreeBSD.org>
CommitDate: 2024-01-02 01:12:45 +0000

    powerpc: Avoid ignoring copyin()'s return value
    
    A recent change made it possible for cpu_set_upcall() to return an
    error.  Do that here instead of ignoring an error from copyin().
    
    Reviewed by:    jhibbits
    MFC after:      1 week
    Differential Revision:  https://reviews.freebsd.org/D43105
    
    (cherry picked from commit bdf03b4bcc4a9aa0be503dbc64415e6b0b845fbc)
---
 sys/powerpc/powerpc/exec_machdep.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/sys/powerpc/powerpc/exec_machdep.c b/sys/powerpc/powerpc/exec_machdep.c
index 341b78b018b6..4c7eba0b2965 100644
--- a/sys/powerpc/powerpc/exec_machdep.c
+++ b/sys/powerpc/powerpc/exec_machdep.c
@@ -1069,6 +1069,9 @@ cpu_set_upcall(struct thread *td, void (*entry)(void *), void *arg,
 {
 	struct trapframe *tf;
 	uintptr_t sp;
+	#ifdef __powerpc64__
+	int error;
+	#endif
 
 	tf = td->td_frame;
 	/* align stack and alloc space for frame ptr and saved LR */
@@ -1096,10 +1099,12 @@ cpu_set_upcall(struct thread *td, void (*entry)(void *), void *arg,
 			tf->srr0 = (register_t)entry;
 			/* ELFv2 ABI requires that the global entry point be in r12. */
 			tf->fixreg[12] = (register_t)entry;
-		}
-		else {
+		} else {
 			register_t entry_desc[3];
-			(void)copyin((void *)entry, entry_desc, sizeof(entry_desc));
+			error = copyin((void *)entry, entry_desc,
+			    sizeof(entry_desc));
+			if (error != 0)
+				return (error);
 			tf->srr0 = entry_desc[0];
 			tf->fixreg[2] = entry_desc[1];
 			tf->fixreg[11] = entry_desc[2];