Index: firmware/target/arm/as3525/sd-as3525v2.c =================================================================== --- firmware/target/arm/as3525/sd-as3525v2.c (revision 29645) +++ firmware/target/arm/as3525/sd-as3525v2.c (working copy) @@ -831,7 +831,6 @@ int retry_all = 0; int const retry_data_max = 100; /* Generous, methinks */ int retry_data; - unsigned int real_numblocks; mutex_lock(&sd_mtx); #ifndef BOOTLOADER @@ -845,6 +844,13 @@ goto sd_transfer_error_no_dma; } + if ((card_info[drive].initialized > 0) && + ((start+count) > card_info[drive].numblocks)) + { + ret = -19; + goto sd_transfer_error_no_dma; + } + /* skip SanDisk OF */ if (drive == INTERNAL_AS3525) start += AMS_OF_SIZE; @@ -861,18 +867,6 @@ goto sd_transfer_error_no_dma; } - /* Check the real block size after the card has been initialized */ - real_numblocks = card_info[drive].numblocks; - /* 'start' represents the real (physical) starting sector - * so we must compare it to the real (physical) number of sectors */ - if (drive == INTERNAL_AS3525) - real_numblocks += AMS_OF_SIZE; - if ((start+count) > real_numblocks) - { - ret = -19; - goto sd_transfer_error_no_dma; - } - /* CMD7 w/rca: Select card to put it in TRAN state */ if(!send_cmd(drive, SD_SELECT_CARD, card_info[drive].rca, MCI_NO_RESP, NULL)) {