From: Vincent Palatin <vpalatin@chromium.org>
To: Qemu devel <qemu-devel@nongnu.org>
Cc: Vincent Palatin <vpalatin@chromium.org>
Subject: [Qemu-devel] [PATCH 2/7] sd: fix card size checking on R/W accesses
Date: Mon, 25 Jul 2011 16:19:06 -0700 [thread overview]
Message-ID: <1311635951-11047-3-git-send-email-vpalatin@chromium.org> (raw)
In-Reply-To: <1311635951-11047-1-git-send-email-vpalatin@chromium.org>
We need to check that we are not crossing the boundaries of the card for
the current access not for the next one which might not happen.
Signed-off-by: Vincent Palatin <vpalatin@chromium.org>
---
hw/sd.c | 22 ++++++++++++----------
1 files changed, 12 insertions(+), 10 deletions(-)
diff --git a/hw/sd.c b/hw/sd.c
index f48d589..de477fe 100644
--- a/hw/sd.c
+++ b/hw/sd.c
@@ -1451,11 +1451,6 @@ void sd_write_data(SDState *sd, uint8_t value)
sd->data[sd->data_offset ++] = value;
if (sd->data_offset >= sd->blk_len) {
/* TODO: Check CRC before committing */
- sd->state = sd_programming_state;
- BLK_WRITE_BLOCK(sd->data_start, sd->data_offset);
- sd->blk_written ++;
- sd->data_start += sd->blk_len;
- sd->data_offset = 0;
if (sd->data_start + sd->blk_len > sd->size) {
sd->card_status |= ADDRESS_ERROR;
break;
@@ -1464,6 +1459,11 @@ void sd_write_data(SDState *sd, uint8_t value)
sd->card_status |= WP_VIOLATION;
break;
}
+ sd->state = sd_programming_state;
+ BLK_WRITE_BLOCK(sd->data_start, sd->data_offset);
+ sd->blk_written ++;
+ sd->data_start += sd->blk_len;
+ sd->data_offset = 0;
sd->csd[14] |= 0x40;
/* Bzzzzzzztt .... Operation complete. */
@@ -1606,17 +1606,19 @@ uint8_t sd_read_data(SDState *sd)
break;
case 18: /* CMD18: READ_MULTIPLE_BLOCK */
- if (sd->data_offset == 0)
+ if (sd->data_offset == 0) {
+ if (sd->data_start + io_len > sd->size) {
+ sd->card_status |= ADDRESS_ERROR;
+ ret = 0;
+ break;
+ }
BLK_READ_BLOCK(sd->data_start, io_len);
+ }
ret = sd->data[sd->data_offset ++];
if (sd->data_offset >= io_len) {
sd->data_start += io_len;
sd->data_offset = 0;
- if (sd->data_start + io_len > sd->size) {
- sd->card_status |= ADDRESS_ERROR;
- break;
- }
}
break;
--
1.7.3.1
next prev parent reply other threads:[~2011-07-25 23:19 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-07-25 23:19 [Qemu-devel] sd: add SDHCI and eMMC support Vincent Palatin
2011-07-25 23:19 ` [Qemu-devel] [PATCH 1/7] sd: do not add one sector to the disk size Vincent Palatin
2011-07-25 23:19 ` Vincent Palatin [this message]
2011-07-30 5:50 ` [Qemu-devel] [PATCH 2/7] sd: fix card size checking on R/W accesses andrzej zaborowski
2011-07-25 23:19 ` [Qemu-devel] [PATCH 3/7] block: add eMMC block device type Vincent Palatin
2011-07-25 23:19 ` [Qemu-devel] [PATCH 4/7] sd: add eMMC support Vincent Palatin
2011-07-25 23:19 ` [Qemu-devel] [PATCH 5/7] sd: add PCI ids for SDHCI controller Vincent Palatin
2011-07-25 23:19 ` [Qemu-devel] [PATCH 6/7] sd: add SD Host Controller (SDHCI) emulation Vincent Palatin
2011-07-25 23:19 ` [Qemu-devel] [PATCH 7/7] sd: compile SDHCI on PCI platforms Vincent Palatin
2011-12-13 16:38 ` [Qemu-devel] sd: add SDHCI and eMMC support Stefan Hajnoczi
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=1311635951-11047-3-git-send-email-vpalatin@chromium.org \
--to=vpalatin@chromium.org \
--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).