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: 15756 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 2BA3A23E3E for ; Thu, 28 Mar 2013 18:43:10 +0000 (UTC) Received: from mail-ve0-f171.google.com (mail-ve0-f171.google.com [209.85.128.171]) by fiordland.canonical.com (Postfix) with ESMTP id DC3D1A1892A for ; Thu, 28 Mar 2013 18:43:09 +0000 (UTC) Received: by mail-ve0-f171.google.com with SMTP id b10so8436987vea.2 for ; Thu, 28 Mar 2013 11:43:09 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:x-forwarded-to:x-forwarded-for:delivered-to:x-received :received-spf:from:to:cc:subject:date:message-id:x-mailer :x-gm-message-state; bh=4AXduqXnAe7uolIAz9Bk7N/71CaPV7Er9WjGYxZCq+w=; b=dgcwWCP9vnNoufO2BhMKYF09nAD4+Qim665Gh29Ipqtxp2gKWljtdWnnLz5b6PxuGk 6wovKywOeUsSSjW69jVTaDcbzOJnUPJFvEUG3EnJc1paAqD0fsijpG6hW4kALNTfVBdq DX56vKGvJ0C2RVHBHiWMBI6KGkKLw0URm/c4JA46OQu9SEmZjmQ+5SH1wVxW0LvRlASc Te6FMSmecGx2B0LZGBO4OM1+wxJB/yCcC/8grC3msrWzVtCU1uBtwSZtctqReDXvXg8k t0NK01EY9F5DV3mI9cXORgX61AumXuZl3Hfh/aeQerCMcxd4liRc3Oflq2YAdTueMyFN Z7YQ== X-Received: by 10.220.153.143 with SMTP id k15mr28257812vcw.33.1364496189405; Thu, 28 Mar 2013 11:43:09 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.59.4.204 with SMTP id cg12csp28834ved; Thu, 28 Mar 2013 11:43:08 -0700 (PDT) X-Received: by 10.194.172.71 with SMTP id ba7mr40239434wjc.26.1364496188456; Thu, 28 Mar 2013 11:43:08 -0700 (PDT) Received: from mnementh.archaic.org.uk (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]) by mx.google.com with ESMTPS id cu4si4516961wib.127.2013.03.28.11.43.07 (version=TLSv1 cipher=RC4-SHA bits=128/128); Thu, 28 Mar 2013 11:43:08 -0700 (PDT) Received-SPF: neutral (google.com: 2001:8b0:1d0::1 is neither permitted nor denied by best guess record for domain of pm215@archaic.org.uk) client-ip=2001:8b0:1d0::1; Authentication-Results: mx.google.com; spf=neutral (google.com: 2001:8b0:1d0::1 is neither permitted nor denied by best guess record for domain of pm215@archaic.org.uk) smtp.mail=pm215@archaic.org.uk 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 Cc: patches@linaro.org, Michael Walle , Anthony Liguori Subject: [PATCH] hw/milkymist-softusb: set buffer in softusb_read_{dmem, pmem} error path 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-Gm-Message-State: ALoCoQlLbzT+FBv3eUIE59MZeK49x/UNcgenXRQZ43NbIp/YKLW5YvXy9DO7GkkzLdlHBmqpa3sg 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; }