diff --git a/sys/compat/freebsd32/freebsd32_misc.c b/sys/compat/freebsd32/freebsd32_misc.c --- a/sys/compat/freebsd32/freebsd32_misc.c +++ b/sys/compat/freebsd32/freebsd32_misc.c @@ -2673,11 +2673,9 @@ error = userland_sysctl(td, name, uap->namelen, uap->old, &oldlen, 1, uap->new, uap->newlen, &j, SCTL_MASK32); - if (error) - return (error); - if (uap->oldlenp) - suword32(uap->oldlenp, j); - return (0); + if (error == 0 && uap->oldlenp != NULL) + error = suword32(uap->oldlenp, j); + return (error); } int