From: Harmandeep Kaur <write.harmandeep@gmail.com>
To: Eric Blake <eblake@redhat.com>
Cc: Stefan Hajnoczi <stefanha@gmail.com>,
Riku Voipio <riku.voipio@iki.fi>,
qemu-devel <qemu-devel@nongnu.org>
Subject: Re: [Qemu-devel] [PATCH v2] linux-user/syscall.c: malloc()/calloc() to g_malloc()/g_try_malloc()/g_new0()
Date: Thu, 1 Oct 2015 21:30:58 +0530 [thread overview]
Message-ID: <CAPtdW16SRC+7un8s4S1VP5SPth4r6eQAmL+mk1KwYrQMVYFOyg@mail.gmail.com> (raw)
In-Reply-To: <560D57CF.1040401@redhat.com>
[-- Attachment #1: Type: text/plain, Size: 1595 bytes --]
Thank you Eric for guiding me in the right direction.
I look forward to implement this correctly.
On Thu, Oct 1, 2015 at 9:27 PM, Eric Blake <eblake@redhat.com> wrote:
> On 09/30/2015 11:32 PM, Harmandeep Kaur wrote:
> > Convert malloc()/calloc() calls to g_malloc()/g_try_malloc()/g_new0()
> > in linux-user/syscall.c file
>
> This part is fine,
>
> >
> > v1->v2 convert the free() call in host_to_target_semarray()
> > to g_free() and calls g_try_malloc(count) instead of
> > g_try_malloc(sizeof(count))
>
> but this part belongs...
>
> >
> > Signed-off-by: Harmandeep Kaur <write.harmandeep@gmail.com>
> > ---
>
> ...here, after the --- separator. It is useful information to mail
> reviewers, but worthless in the qemu.git history (a year from now, we
> won't care how many versions it went through on the list, only the
> version that got checked in).
>
>
> > +++ b/linux-user/syscall.c
> > @@ -1554,12 +1554,7 @@ set_timeout:
> > }
> >
> > fprog.len = tswap16(tfprog->len);
> > - filter = malloc(fprog.len * sizeof(*filter));
> > - if (filter == NULL) {
> > - unlock_user_struct(tfilter, tfprog->filter, 1);
> > - unlock_user_struct(tfprog, optval_addr, 1);
> > - return -TARGET_ENOMEM;
> > - }
> > + filter = g_malloc(fprog.len * sizeof(*filter));
>
> This should use g_new(TYPE, fprog.len) to avoid overflow issues.
>
> --
> Eric Blake eblake redhat com +1-919-301-3266
> Libvirt virtualization library http://libvirt.org
>
>
[-- Attachment #2: Type: text/html, Size: 2459 bytes --]
next prev parent reply other threads:[~2015-10-01 16:01 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-10-01 5:32 [Qemu-devel] [PATCH v2] linux-user/syscall.c: malloc()/calloc() to g_malloc()/g_try_malloc()/g_new0() Harmandeep Kaur
2015-10-01 15:57 ` Eric Blake
2015-10-01 16:00 ` Harmandeep Kaur [this message]
2015-10-01 16:03 ` Peter Maydell
2015-10-01 16:12 ` Harmandeep Kaur
2015-10-01 16:23 ` Harmandeep Kaur
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAPtdW16SRC+7un8s4S1VP5SPth4r6eQAmL+mk1KwYrQMVYFOyg@mail.gmail.com \
--to=write.harmandeep@gmail.com \
--cc=eblake@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=riku.voipio@iki.fi \
--cc=stefanha@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).