From patchwork Thu Mar 28 18:43:04 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 232168 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 4E3642C00B9 for ; Fri, 29 Mar 2013 05:43:33 +1100 (EST) Received: from localhost ([::1]:36634 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ULHnP-0007gb-J1 for incoming@patchwork.ozlabs.org; Thu, 28 Mar 2013 14:43:31 -0400 Received: from eggs.gnu.org ([208.118.235.92]:43511) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ULHn7-0007dX-FP for qemu-devel@nongnu.org; Thu, 28 Mar 2013 14:43:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ULHn3-0008Ma-8c for qemu-devel@nongnu.org; Thu, 28 Mar 2013 14:43:13 -0400 Received: from 1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.d.1.0.0.b.8.0.1.0.0.2.ip6.arpa ([2001:8b0:1d0::1]:33308 helo=mnementh.archaic.org.uk) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ULHn3-0008ML-22 for qemu-devel@nongnu.org; Thu, 28 Mar 2013 14:43:09 -0400 Received: from pm215 by mnementh.archaic.org.uk with local (Exim 4.72) (envelope-from ) id 1ULHmy-00037t-4d; Thu, 28 Mar 2013 18:43:04 +0000 From: Peter Maydell To: qemu-devel@nongnu.org Date: Thu, 28 Mar 2013 18:43:04 +0000 Message-Id: <1364496184-11994-1-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 1.7.2.5 X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2001:8b0:1d0::1 Cc: Michael Walle , Anthony Liguori , patches@linaro.org Subject: [Qemu-devel] [PATCH] hw/milkymist-softusb: set buffer in softusb_read_{dmem, pmem} error path X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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 Acked-By: Michael Walle --- 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; }