diff mbox series

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

Message ID 20230726063454.247-1-dinglimin@cmss.chinamobile.com
State New
Headers show
Series os-sys.c:do_freebsd_sysctl The unuser_lock for hnewp and hnamep is missing | expand

Commit Message

dinglimin July 26, 2023, 6:34 a.m. UTC
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 mbox series

Patch

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;
 }