From: Liu Yu <yu.liu@freescale.com>
To: qemu-devel@nongnu.org
Cc: Liu Yu <yu.liu@freescale.com>
Subject: [Qemu-devel] [PATCH] ppc/e500_pci: Fix an array overflow issue
Date: Tue, 27 Sep 2011 16:17:19 +0800 [thread overview]
Message-ID: <1317111439-6478-1-git-send-email-yu.liu@freescale.com> (raw)
Signed-off-by: Liu Yu <yu.liu@freescale.com>
---
hw/ppce500_pci.c | 26 ++++++++++++++++----------
1 files changed, 16 insertions(+), 10 deletions(-)
diff --git a/hw/ppce500_pci.c b/hw/ppce500_pci.c
index 2db365d..3e24e85 100644
--- a/hw/ppce500_pci.c
+++ b/hw/ppce500_pci.c
@@ -108,15 +108,18 @@ static uint32_t pci_reg_read4(void *opaque, target_phys_addr_t addr)
case PPCE500_PCI_IW3:
case PPCE500_PCI_IW2:
- case PPCE500_PCI_IW1:
+ case PPCE500_PCI_IW1: {
+ int idx = ((addr >> 5) & 0x3) - 1;
+
switch (addr & 0xC) {
- case PCI_PITAR: value = pci->pib[(addr >> 5) & 0x3].pitar; break;
- case PCI_PIWBAR: value = pci->pib[(addr >> 5) & 0x3].piwbar; break;
- case PCI_PIWBEAR: value = pci->pib[(addr >> 5) & 0x3].piwbear; break;
- case PCI_PIWAR: value = pci->pib[(addr >> 5) & 0x3].piwar; break;
+ case PCI_PITAR: value = pci->pib[idx].pitar; break;
+ case PCI_PIWBAR: value = pci->pib[idx].piwbar; break;
+ case PCI_PIWBEAR: value = pci->pib[idx].piwbear; break;
+ case PCI_PIWAR: value = pci->pib[idx].piwar; break;
default: break;
};
break;
+ }
case PPCE500_PCI_GASKET_TIMR:
value = pci->gasket_time;
@@ -164,15 +167,18 @@ static void pci_reg_write4(void *opaque, target_phys_addr_t addr,
case PPCE500_PCI_IW3:
case PPCE500_PCI_IW2:
- case PPCE500_PCI_IW1:
+ case PPCE500_PCI_IW1: {
+ int idx = ((addr >> 5) & 0x3) - 1;
+
switch (addr & 0xC) {
- case PCI_PITAR: pci->pib[(addr >> 5) & 0x3].pitar = value; break;
- case PCI_PIWBAR: pci->pib[(addr >> 5) & 0x3].piwbar = value; break;
- case PCI_PIWBEAR: pci->pib[(addr >> 5) & 0x3].piwbear = value; break;
- case PCI_PIWAR: pci->pib[(addr >> 5) & 0x3].piwar = value; break;
+ case PCI_PITAR: pci->pib[idx].pitar = value; break;
+ case PCI_PIWBAR: pci->pib[idx].piwbar = value; break;
+ case PCI_PIWBEAR: pci->pib[idx].piwbear = value; break;
+ case PCI_PIWAR: pci->pib[idx].piwar = value; break;
default: break;
};
break;
+ }
case PPCE500_PCI_GASKET_TIMR:
pci->gasket_time = value;
--
1.6.4
next reply other threads:[~2011-09-27 9:24 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-09-27 8:17 Liu Yu [this message]
2011-09-27 12:45 ` [Qemu-devel] [PATCH] ppc/e500_pci: Fix an array overflow issue Alexander Graf
2011-09-27 16:52 ` [Qemu-devel] [Qemu-ppc] " Scott Wood
2011-09-27 17:01 ` Alexander Graf
2011-09-27 17:04 ` Richard Henderson
2011-09-27 17:04 ` Alexander Graf
2011-09-27 17:06 ` Scott Wood
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=1317111439-6478-1-git-send-email-yu.liu@freescale.com \
--to=yu.liu@freescale.com \
--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).