On Thu, Mar 31, 2016 at 3:12 PM, Stefan Hajnoczi <stefa...@gmail.com> wrote:
> On Wed, Mar 30, 2016 at 09:58:41PM +0530, haris iqbal wrote:
>> On Wed, Mar 30, 2016 at 7:39 PM, Stefan Hajnoczi <stefa...@gmail.com> wrote:
>> > On Thu, Mar 24, 2016 at 12:02:03AM +0530, Md Haris Iqbal wrote:
>> >> Signed-off-by: Md Haris Iqbal <haris.p...@gmail.com>
>> >> ---
>> >>  linux-user/qemu.h | 4 ++--
>> >>  1 file changed, 2 insertions(+), 2 deletions(-)
>> >>
>> >> diff --git a/linux-user/qemu.h b/linux-user/qemu.h
>> >> index 26b0ba2..3c3fd15 100644
>> >> --- a/linux-user/qemu.h
>> >> +++ b/linux-user/qemu.h
>> >> @@ -381,7 +381,7 @@ static inline void *lock_user(int type, abi_ulong 
>> >> guest_addr, long len, int copy
>> >>  #ifdef DEBUG_REMAP
>> >>      {
>> >>          void *addr;
>> >> -        addr = malloc(len);
>> >> +        addr = g_malloc(len);
>> >>          if (copy)
>> >>              memcpy(addr, g2h(guest_addr), len);
>> >>          else
>> >> @@ -407,7 +407,7 @@ static inline void unlock_user(void *host_ptr, 
>> >> abi_ulong guest_addr,
>> >>          return;
>> >>      if (len > 0)
>> >>          memcpy(g2h(guest_addr), host_ptr, len);
>> >> -    free(host_ptr);
>> >> +    g_free(host_ptr);
>> >>  #endif
>> >>  }
>> >
>> > If I understand correctly either lock_user() or lock_user_string() may
>> > be followed by unlock_user().  If you change unlock_user() to g_free()
>> > then you also need to change lock_user_string() to g_malloc() to avoid a
>> > malloc()/g_free() mismatch.
>>
>> lock_user_string() does not use malloc itself, but calls lock_user()
>> from itself.
>
> You are right.  The reason I got confused is because there are 3
> versions of lock_user(): linux-user, bsd-user, and
> include/exec/softmmu-semi.h.
>
> Please send equivalent patches for the other 2 versions as well.  This
> way they stay consistent.

Will do. Actually as they different files, I was told to send patches
separately.

And I wanted to wait till this one is reviewed, so I don't repeat any
mistake if there are in this one.

>
> Thanks,
> Stefan



-- 

With regards,

Md Haris Iqbal,
Placement Coordinator, MTech IT
NITK Surathkal,
Contact: +91 8861996962

Reply via email to