qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH]: Fix size checking in SD Memory Card Physical laye


From: GreenTime
Subject: [Qemu-devel] [PATCH]: Fix size checking in SD Memory Card Physical layer
Date: Wed, 25 Mar 2009 15:33:59 +0800

Hi all,

I found a problem when I use CMD25 to write data into the SD card and write to the end of the storage.
There will be a wrong state which can't accept command problem. I found there may be some codes written wrong in sd.c

sd->data_start += sd->blk_len;                                 //data_start has added blk_len
if (sd->data_start + sd->blk_len > sd->size) {             //so it should not be added again when checking sd->size

--- a/trunk/hw/sd.c
+++ b/trunk/hw/sd.c

@@ -1414,7 +1414,7 @@ void sd_write_data(SDState *sd, uint8_t value)
             sd->blk_written ++;
             sd->data_start += sd->blk_len;
             sd->data_offset = 0;
-            if (sd->data_start + sd->blk_len > sd->size) {
+            if (sd->data_start > sd->size) {
                 sd->card_status |= ADDRESS_ERROR;
                 break;
             }
@@ -1537,7 +1537,7 @@ uint8_t sd_read_data(SDState *sd)
         if (sd->data_offset >= sd->blk_len) {
             sd->data_start += sd->blk_len;
             sd->data_offset = 0;
-            if (sd->data_start + sd->blk_len > sd->size) {
+            if (sd->data_start > sd->size) {
                 sd->card_status |= ADDRESS_ERROR;
                 break;
             }
@@ -1568,7 +1568,7 @@ uint8_t sd_read_data(SDState *sd)
         if (sd->data_offset >= sd->blk_len) {
             sd->data_start += sd->blk_len;
             sd->data_offset = 0;
-            if (sd->data_start + sd->blk_len > sd->size) {
+            if (sd->data_start > sd->size) {
                 sd->card_status |= ADDRESS_ERROR;
                 break;
             }

--

GreenTime
: )

reply via email to

[Prev in Thread] Current Thread [Next in Thread]