qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] hw/milkymist-softusb: set buffer in softusb_read_{dmem, pmem} error path
@ 2013-03-28 18:43 Peter Maydell
  2013-03-28 18:50 ` Michael Walle
  2013-04-01 20:36 ` Anthony Liguori
  0 siblings, 2 replies; 3+ messages in thread
From: Peter Maydell @ 2013-03-28 18:43 UTC (permalink / raw)
  To: qemu-devel; +Cc: Michael Walle, Anthony Liguori, patches

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

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [Qemu-devel] [PATCH] hw/milkymist-softusb: set buffer in softusb_read_{dmem, pmem} error path
  2013-03-28 18:43 [Qemu-devel] [PATCH] hw/milkymist-softusb: set buffer in softusb_read_{dmem, pmem} error path Peter Maydell
@ 2013-03-28 18:50 ` Michael Walle
  2013-04-01 20:36 ` Anthony Liguori
  1 sibling, 0 replies; 3+ messages in thread
From: Michael Walle @ 2013-03-28 18:50 UTC (permalink / raw)
  To: Peter Maydell; +Cc: Anthony Liguori, qemu-devel, patches

Am Donnerstag 28 März 2013, 19:43:04 schrieb Peter Maydell:
> 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;
>      }

Acked-By: Michael Walle <michael@walle.cc>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Qemu-devel] [PATCH] hw/milkymist-softusb: set buffer in softusb_read_{dmem, pmem} error path
  2013-03-28 18:43 [Qemu-devel] [PATCH] hw/milkymist-softusb: set buffer in softusb_read_{dmem, pmem} error path Peter Maydell
  2013-03-28 18:50 ` Michael Walle
@ 2013-04-01 20:36 ` Anthony Liguori
  1 sibling, 0 replies; 3+ messages in thread
From: Anthony Liguori @ 2013-04-01 20:36 UTC (permalink / raw)
  To: Peter Maydell, qemu-devel; +Cc: Michael Walle, Anthony Liguori, patches

Applied.  Thanks.

Regards,

Anthony Liguori

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2013-04-01 20:36 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-03-28 18:43 [Qemu-devel] [PATCH] hw/milkymist-softusb: set buffer in softusb_read_{dmem, pmem} error path Peter Maydell
2013-03-28 18:50 ` Michael Walle
2013-04-01 20:36 ` Anthony Liguori

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).