qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Peter Xu <peterx@redhat.com>
To: Peter Maydell <peter.maydell@linaro.org>
Cc: qemu-devel@nongnu.org, Juan Quintela <quintela@redhat.com>,
	Fabiano Rosas <farosas@suse.de>
Subject: Re: [PATCH] migration: Fix parse_ramblock() on overwritten retvals
Date: Thu, 19 Oct 2023 10:50:12 -0400	[thread overview]
Message-ID: <ZTFCJLnmdf6l/LJp@x1n> (raw)
In-Reply-To: <CAFEAcA-xOf+TLL9jbjQvdaqOK0ew_xbjnoajTzaxLbkhEz9Vig@mail.gmail.com>

On Thu, Oct 19, 2023 at 01:40:29PM +0100, Peter Maydell wrote:
> On Tue, 17 Oct 2023 at 21:40, Peter Xu <peterx@redhat.com> wrote:
> >
> > It's possible that some errors can be overwritten with success retval later
> > on, and then ignored.  Always capture all errors and report.
> >
> > Reported by Coverity 1522861, but actually I spot one more in the same
> > function.
> 
> The other one is CID 1522862, I think.

Yes..

> 
> > Fixes: CID 1522861
> > Signed-off-by: Peter Xu <peterx@redhat.com>
> 
> > ---
> >  migration/ram.c | 6 ++++--
> >  1 file changed, 4 insertions(+), 2 deletions(-)
> >
> > diff --git a/migration/ram.c b/migration/ram.c
> > index c844151ee9..d8bdb53a8f 100644
> > --- a/migration/ram.c
> > +++ b/migration/ram.c
> > @@ -3888,6 +3888,8 @@ static int parse_ramblock(QEMUFile *f, RAMBlock *block, ram_addr_t length)
> >          ret = qemu_ram_resize(block, length, &local_err);
> >          if (local_err) {
> >              error_report_err(local_err);
> > +            assert(ret < 0);
> 
> We usually don't bother asserting for this kind of "function
> reports errors two ways" code.

Juan, please feel free to drop the assert() if it's in the queue.

After this one lands, I'll send a patch to remove qemu_ram_resize retval
and only rely on Error*.

Thanks,

-- 
Peter Xu



      reply	other threads:[~2023-10-19 14:50 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-17 20:38 [PATCH] migration: Fix parse_ramblock() on overwritten retvals Peter Xu
2023-10-17 22:30 ` Fabiano Rosas
2023-10-18  7:12 ` Juan Quintela
2023-10-18 13:16   ` Peter Xu
2023-10-18 13:54 ` Juan Quintela
2023-10-19 12:40 ` Peter Maydell
2023-10-19 14:50   ` Peter Xu [this message]

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=ZTFCJLnmdf6l/LJp@x1n \
    --to=peterx@redhat.com \
    --cc=farosas@suse.de \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=quintela@redhat.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).