Index: firmware/target/arm/as3525/sd-as3525v2.c =================================================================== --- firmware/target/arm/as3525/sd-as3525v2.c (revision 29635) +++ firmware/target/arm/as3525/sd-as3525v2.c (working copy) @@ -844,11 +844,6 @@ goto sd_transfer_error_no_dma; } - if((start+count) > card_info[drive].numblocks) - { - ret = -19; - goto sd_transfer_error_no_dma; - } /* skip SanDisk OF */ if (drive == INTERNAL_AS3525) @@ -866,6 +861,12 @@ goto sd_transfer_error_no_dma; } + if((drive == INTERNAL_AS3525 && (start+count-AMS_OF_SIZE) > card_info[drive].numblocks) || (drive != INTERNAL_AS3525 && (start+count) > card_info[drive].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)) {