qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Peter Maydell <peter.maydell@linaro.org>
To: qemu-devel@nongnu.org
Cc: Michael Walle <michael@walle.cc>,
	Anthony Liguori <aliguori@us.ibm.com>,
	patches@linaro.org
Subject: [Qemu-devel] [PATCH] hw/milkymist-softusb: set buffer in softusb_read_{dmem, pmem} error path
Date: Thu, 28 Mar 2013 18:43:04 +0000	[thread overview]
Message-ID: <1364496184-11994-1-git-send-email-peter.maydell@linaro.org> (raw)

Make sure we set the buffer to something in the softusb_read_{dmem,pmem}
error paths, since the caller will use the buffer unconditionally.
(Newer gcc is smart enough to spot this and complain about 'may be
used uninitialized'.)

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
This needs to be applied before the 'drop sysbus_add_mem' patchset to
fix a compilation failure with newer gcc. That patchset should apply
after this without needing rebase, I think.

 hw/milkymist-softusb.c |    2 ++
 1 file changed, 2 insertions(+)

diff --git a/hw/milkymist-softusb.c b/hw/milkymist-softusb.c
index d911686..9f83209 100644
--- a/hw/milkymist-softusb.c
+++ b/hw/milkymist-softusb.c
@@ -131,6 +131,7 @@ static inline void softusb_read_dmem(MilkymistSoftUsbState *s,
     if (offset + len >= s->dmem_size) {
         error_report("milkymist_softusb: read dmem out of bounds "
                 "at offset 0x%x, len %d", offset, len);
+        memset(buf, 0, len);
         return;
     }
 
@@ -155,6 +156,7 @@ static inline void softusb_read_pmem(MilkymistSoftUsbState *s,
     if (offset + len >= s->pmem_size) {
         error_report("milkymist_softusb: read pmem out of bounds "
                 "at offset 0x%x, len %d", offset, len);
+        memset(buf, 0, len);
         return;
     }
 
-- 
1.7.9.5

             reply	other threads:[~2013-03-28 18:43 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-03-28 18:43 Peter Maydell [this message]
2013-03-28 18:50 ` [Qemu-devel] [PATCH] hw/milkymist-softusb: set buffer in softusb_read_{dmem, pmem} error path Michael Walle
2013-04-01 20:36 ` Anthony Liguori

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=1364496184-11994-1-git-send-email-peter.maydell@linaro.org \
    --to=peter.maydell@linaro.org \
    --cc=aliguori@us.ibm.com \
    --cc=michael@walle.cc \
    --cc=patches@linaro.org \
    --cc=qemu-devel@nongnu.org \
    /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).