Skip to contentSkip to conversation

linux-user/syscall.c : Minor cleanups of timer_create handling.

PATCH In review Erik de Castro Lopo 4 participants 9 messages Aug 2, 2014 – Aug 6, 2014

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 linux-user/syscall.c : Minor cleanups of timer_create handling.

* Add missing unlock of user struct.
* Remove unneeded pointer variable.

---
 linux-user/syscall.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
linux-user/syscall.c +3 -3
index a50229d..7d8f54a 100644
@@ -9412,7 +9412,7 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
     {
         /* args: clockid_t clockid, struct sigevent *sevp, timer_t *timerid */
 
-        struct sigevent host_sevp = { {0}, }, *phost_sevp = NULL;
+        struct sigevent host_sevp = { {0}, };
         struct target_sigevent *ptarget_sevp;
         struct target_timer_t *ptarget_timer;
 
@@ -9432,10 +9432,10 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
                 host_sevp.sigev_signo = tswap32(ptarget_sevp->sigev_signo);
                 host_sevp.sigev_notify = tswap32(ptarget_sevp->sigev_notify);
 
-                phost_sevp = &host_sevp;
+                unlock_user_struct(ptarget_sevp, arg2, 0);
             }
 
-            ret = get_errno(timer_create(clkid, phost_sevp, phtimer));
+            ret = get_errno(timer_create(clkid, &host_sevp, phtimer));
             if (ret) {
                 phtimer = NULL;
             } else {
Signature · 1 line
2.0.1
#1 lore raw
Quoted 24 lines · Erik de Castro Lopo

* Add missing unlock of user struct.
* Remove unneeded pointer variable.

---
 linux-user/syscall.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
linux-user/syscall.c +1 -1
index a50229d..7d8f54a 100644
@@ -9412,7 +9412,7 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
     {
         /* args: clockid_t clockid, struct sigevent *sevp, timer_t *timerid */
 
-        struct sigevent host_sevp = { {0}, }, *phost_sevp = NULL;
+        struct sigevent host_sevp = { {0}, };
         struct target_sigevent *ptarget_sevp;
         struct target_timer_t *ptarget_timer;
 
@@ -9432,10 +9432,10 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
                 host_sevp.sigev_signo = tswap32(ptarget_sevp->sigev_signo);
                 host_sevp.sigev_notify = tswap32(ptarget_sevp->sigev_notify);

linux-user/syscall.c abi_long do_syscall(void *cpu_env, int num, abi_long arg1, · line 9441

Quoted 10 lines
linux-user/syscall.c +2 -2
 
-                phost_sevp = &host_sevp;
+                unlock_user_struct(ptarget_sevp, arg2, 0);
             }
 
-            ret = get_errno(timer_create(clkid, phost_sevp, phtimer));
+            ret = get_errno(timer_create(clkid, &host_sevp, phtimer));
             if (ret) {
                 phtimer = NULL;
             } else {

Doesn't this turn a timer_create(clkid, NULL, phtimer) into a timer_create(clkid, something-not-NULL, phtimer) ? That doesn't seem right to me (and the code you've deleted here is the common idiom in syscall.c for handling those "arg is pointer-to-struct-or-NULL" cases).

thanks
-- PMM

#2 lore raw
Quoted 5 lines · Peter Maydell

Doesn't this turn a timer_create(clkid, NULL, phtimer) into a timer_create(clkid, something-not-NULL, phtimer) ? That doesn't seem right to me (and the code you've deleted here is the common idiom in syscall.c for handling those "arg is pointer-to-struct-or-NULL" cases).

You're right. Thanks. I will amend this.

Erik

Signature · 3 lines
----------------------------------------------------------------------
Erik de Castro Lopo
http://www.mega-nerd.com/
#3 lore raw
Quoted 9 lines · Erik de Castro Lopo
Quoted 5 lines · Peter Maydell

Doesn't this turn a timer_create(clkid, NULL, phtimer) into a timer_create(clkid, something-not-NULL, phtimer) ? That doesn't seem right to me (and the code you've deleted here is the common idiom in syscall.c for handling those "arg is pointer-to-struct-or-NULL" cases).

You're right. Thanks. I will amend this.

Amend it to what? The current code looks fine to me, so I'm not sure what bug you're trying to fix here.

thanks
-- PMM

#4 lore raw
Quoted 2 lines · Peter Maydell

Amend it to what? The current code looks fine to me, so I'm not sure what bug you're trying to fix here.

There is still a missing call to unlock_user_struct() inside the "if (arg2)" block. Is that not worth fixing?

Erik

Signature · 3 lines
----------------------------------------------------------------------
Erik de Castro Lopo
http://www.mega-nerd.com/
#5 lore raw
Quoted 7 lines · Erik de Castro Lopo
Quoted 2 lines · Peter Maydell

Amend it to what? The current code looks fine to me, so I'm not sure what bug you're trying to fix here.

There is still a missing call to unlock_user_struct() inside the "if (arg2)" block. Is that not worth fixing?

Oops, yes; sorry, I missed that part of your commit message.

-- PMM

#6 lore raw

PATCH 1/1 linux-user: Add missing unlock_user_struct to timer_create.

In reply to Erik de Castro Lopo
---
 linux-user/syscall.c | 1 +
 1 file changed, 1 insertion(+)
linux-user/syscall.c +1 -0
index a50229d..5f22b37 100644
@@ -9432,6 +9432,7 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
                 host_sevp.sigev_signo = tswap32(ptarget_sevp->sigev_signo);
                 host_sevp.sigev_notify = tswap32(ptarget_sevp->sigev_notify);
 
+                unlock_user_struct(ptarget_sevp, arg2, 0);
                 phost_sevp = &host_sevp;
             }
 
Signature · 1 line
2.0.1
Reviewed-by on v1 1/1
#7 lore raw

Re: [Qemu-devel] [PATCH] linux-user: Add missing unlock_user_struct to timer_create.

Quoted 10 lines · Erik de Castro Lopo
---
 linux-user/syscall.c | 1 +
 1 file changed, 1 insertion(+)
linux-user/syscall.c +0 -0
index a50229d..5f22b37 100644

linux-user/syscall.c abi_long do_syscall(void *cpu_env, int num, abi_long arg1,

Quoted 8 lines
linux-user/syscall.c +1 -1
@@ -9432,6 +9432,7 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
                 host_sevp.sigev_signo = tswap32(ptarget_sevp->sigev_signo);
                 host_sevp.sigev_notify = tswap32(ptarget_sevp->sigev_notify);
 
+                unlock_user_struct(ptarget_sevp, arg2, 0);
                 phost_sevp = &host_sevp;
             }
 
--

thanks
-- PMM

Applied
#8 lore raw

Re: [Qemu-devel] [PATCH] linux-user: Add missing unlock_user_struct to timer_create.

In reply to Erik de Castro Lopo
Quoted 1 line · Erik de Castro Lopo

Thanks,

applied to linux-user tree.

Quoted 19 lines
---
 linux-user/syscall.c | 1 +
 1 file changed, 1 insertion(+)
linux-user/syscall.c +1 -0
index a50229d..5f22b37 100644
@@ -9432,6 +9432,7 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
                 host_sevp.sigev_signo = tswap32(ptarget_sevp->sigev_signo);
                 host_sevp.sigev_notify = tswap32(ptarget_sevp->sigev_notify);
 
+                unlock_user_struct(ptarget_sevp, arg2, 0);
                 phost_sevp = &host_sevp;
             }
 
Signature · 1 line
2.0.1