From: "Michael S. Tsirkin" <mst@redhat.com>
To: qemu-devel@nongnu.org, quintela@redhat.com
Subject: [Qemu-devel] [PATCH] qemu/pci: clarify pci config load routine
Date: Mon, 5 Oct 2009 22:46:11 +0200 [thread overview]
Message-ID: <20091005204611.GA4384@redhat.com> (raw)
PCI load routine has to be called with size equal to 256 (otherwise it
will crash in weird ways). So assert this, making code clearer.
Also avoid dynamically sized array on stack - good for portability.
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Cc: Juan Quintela <quintela@redhat.com>
---
hw/pci.c | 9 +++++----
1 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/hw/pci.c b/hw/pci.c
index ade778f..196297a 100644
--- a/hw/pci.c
+++ b/hw/pci.c
@@ -193,14 +193,15 @@ int pci_bus_num(PCIBus *s)
static int get_pci_config_device(QEMUFile *f, void *pv, size_t size)
{
PCIDevice *s = container_of(pv, PCIDevice, config);
- uint8_t config[size];
+ uint8_t config[PCI_CONFIG_SPACE_SIZE];
int i;
- qemu_get_buffer(f, config, size);
- for (i = 0; i < size; ++i)
+ assert(size == sizeof config);
+ qemu_get_buffer(f, config, sizeof config);
+ for (i = 0; i < sizeof config; ++i)
if ((config[i] ^ s->config[i]) & s->cmask[i] & ~s->wmask[i])
return -EINVAL;
- memcpy(s->config, config, size);
+ memcpy(s->config, config, sizeof config);
pci_update_mappings(s);
--
1.6.5.rc2
next reply other threads:[~2009-10-05 20:48 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-10-05 20:46 Michael S. Tsirkin [this message]
2009-10-05 22:47 ` [Qemu-devel] Re: [PATCH] qemu/pci: clarify pci config load routine Juan Quintela
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=20091005204611.GA4384@redhat.com \
--to=mst@redhat.com \
--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).