[PATCH] os-sys.c:do_freebsd_sysctl The unuser_lock for hnewp and hnamep is missing

dinglimin posted 1 patch 9 months, 3 weeks ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20230726063454.247-1-dinglimin@cmss.chinamobile.com
Maintainers: Warner Losh <imp@bsdimp.com>, Kyle Evans <kevans@freebsd.org>
bsd-user/freebsd/os-sys.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
[PATCH] os-sys.c:do_freebsd_sysctl The unuser_lock for hnewp and hnamep is missing
Posted by dinglimin 9 months, 3 weeks ago
If holdp returns NULL, you need to execute unuser_lock on hnewp and hnamep when exiting the function

Signed-off-by: dinglimin <dinglimin@cmss.chinamobile.com>
---
 bsd-user/freebsd/os-sys.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/bsd-user/freebsd/os-sys.c b/bsd-user/freebsd/os-sys.c
index df31706558..3918ddf1ed 100644
--- a/bsd-user/freebsd/os-sys.c
+++ b/bsd-user/freebsd/os-sys.c
@@ -585,9 +585,10 @@ abi_long do_freebsd_sysctl(CPUArchState *env, abi_ulong namep, int32_t namelen,
     if (oldlenp && (ret == 0 || ret == -TARGET_ENOMEM)) {
         put_user_ual(holdlen, oldlenp);
     }
-    unlock_user(hnamep, namep, 0);
     unlock_user(holdp, oldp, ret == 0 ? holdlen : 0);
 out:
+    unlock_user(hnamep, namep, 0);
+    unlock_user(hnewp, newp, 0);
     g_free(snamep);
     return ret;
 }
-- 
2.30.0.windows.2