git: c6224994ac70 - main - freebsd32: Fix freebsd11_nstat copyout condition

From: Mitchell Horne <mhorne_at_FreeBSD.org>
Date: Thu, 09 Apr 2026 16:52:18 UTC
The branch main has been updated by mhorne:

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

commit c6224994ac70b4f71ef9e11903bb2e50ed2b1bfe
Author:     Weixie Cui <cuiweixie@gmail.com>
AuthorDate: 2026-03-31 10:12:32 +0000
Commit:     Mitchell Horne <mhorne@FreeBSD.org>
CommitDate: 2026-04-09 16:46:23 +0000

    freebsd32: Fix freebsd11_nstat copyout condition
    
    freebsd11_freebsd32_nstat() invoked copyout(2) when
    freebsd11_cvtnstat32() failed and skipped copyout on success. This is
    backwards.
    
    Fix this to match freebsd11_freebsd32_nlstat() and freebsd11_nstat(),
    and only copy the nstat32 result to userspace when conversion succeeds.
    
    Signed-off-by:  Weixie Cui <cuiweixie@gmail.com>
    Reviewed by:    mhorne
    MFC after:      1 week
    Pull Request:   https://github.com/freebsd/freebsd-src/pull/2109
---
 sys/compat/freebsd32/freebsd32_misc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sys/compat/freebsd32/freebsd32_misc.c b/sys/compat/freebsd32/freebsd32_misc.c
index 4ec6dd452b32..a0b6118900ed 100644
--- a/sys/compat/freebsd32/freebsd32_misc.c
+++ b/sys/compat/freebsd32/freebsd32_misc.c
@@ -2649,7 +2649,7 @@ freebsd11_freebsd32_nstat(struct thread *td,
 	if (error != 0)
 		return (error);
 	error = freebsd11_cvtnstat32(&sb, &nsb);
-	if (error != 0)
+	if (error == 0)
 		error = copyout(&nsb, uap->ub, sizeof (nsb));
 	return (error);
 }