qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Juan Quintela <quintela@redhat.com>
To: Alvise Rigo <a.rigo@virtualopensystems.com>
Cc: Orit Wasserman <owasserm@redhat.com>,
	tech@virtualopensystems.com, qemu-devel@nongnu.org,
	Eduardo Habkost <ehabkost@redhat.com>
Subject: Re: [Qemu-devel] [RFC 1/4] Fix issue affecting get_int32_le() in vmstate.c
Date: Tue, 25 Feb 2014 19:52:18 +0100	[thread overview]
Message-ID: <87k3cjrpnh.fsf@elfo.mitica> (raw)
In-Reply-To: <1393347170-28502-2-git-send-email-a.rigo@virtualopensystems.com> (Alvise Rigo's message of "Tue, 25 Feb 2014 17:52:47 +0100")

Alvise Rigo <a.rigo@virtualopensystems.com> wrote:
> The method is not behaving in the way it's supposed to. It should return
> the new value only if it's less than the actual one.
>
> Signed-off-by: Alvise Rigo <a.rigo@virtualopensystems.com>

See David patch of this function.  There were a bug, we were doing the
wrong comparison.  But we expect not to chang the local value.  We just
want the the one that cames is less or equal that the current value
(think of an array size, it is a bad idea to try to read a bigger array
into a smaller one).

BTW, did you find this bug by testing or by code inspection?

thanks, Juan.

> ---
>  vmstate.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/vmstate.c b/vmstate.c
> index 284b080..038b274 100644
> --- a/vmstate.c
> +++ b/vmstate.c
> @@ -326,11 +326,11 @@ const VMStateInfo vmstate_info_int32_equal = {
>  
>  static int get_int32_le(QEMUFile *f, void *pv, size_t size)
>  {
> -    int32_t *old = pv;
> -    int32_t new;
> -    qemu_get_sbe32s(f, &new);
> +    int32_t old = *(int32_t *)pv;
> +    int32_t *new = pv;
> +    qemu_get_sbe32s(f, new);
>  
> -    if (*old <= new) {
> +    if (*new <= old) {
>          return 0;
>      }
>      return -EINVAL;

  parent reply	other threads:[~2014-02-25 18:52 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-02-25 16:52 [Qemu-devel] [RFC 0/4] target-arm: KVM to TCG migration Alvise Rigo
2014-02-25 16:52 ` [Qemu-devel] [RFC 1/4] Fix issue affecting get_int32_le() in vmstate.c Alvise Rigo
2014-02-25 18:11   ` Eduardo Habkost
2014-02-25 18:16   ` Peter Maydell
2014-02-25 18:52   ` Juan Quintela [this message]
2014-02-25 18:55     ` Peter Maydell
2014-02-25 16:52 ` [Qemu-devel] [RFC 2/4] Added flag in ARMCPU to track last execution mode Alvise Rigo
2014-02-25 18:19   ` Peter Maydell
2014-02-26  9:16     ` alvise rigo
2014-02-26  9:56       ` Peter Maydell
2014-02-25 16:52 ` [Qemu-devel] [RFC 3/4] Add l2ctlr cp register to CPUARMState Alvise Rigo
2014-02-25 18:22   ` Peter Maydell
2014-02-26  9:17     ` alvise rigo
2014-02-26 10:07       ` Peter Maydell
2014-02-25 16:52 ` [Qemu-devel] [RFC 4/4] Relevant changes to enable KVM to TCG migration Alvise Rigo
2014-02-25 18:25   ` Peter Maydell
2014-02-26 10:02     ` alvise rigo
2014-02-26 10:04       ` Peter Maydell
2014-02-26 10:27         ` alvise rigo
2014-02-26 10:33           ` Peter Maydell
2014-03-03 21:39       ` Peter Maydell
2014-03-05 15:01         ` alvise rigo
2014-03-05 17:11           ` Peter Maydell

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=87k3cjrpnh.fsf@elfo.mitica \
    --to=quintela@redhat.com \
    --cc=a.rigo@virtualopensystems.com \
    --cc=ehabkost@redhat.com \
    --cc=owasserm@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=tech@virtualopensystems.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).