Skip to content
Snippets Groups Projects
Commit d2bf29e3 authored by Lei Wen's avatar Lei Wen Committed by Wolfgang Denk
Browse files

mmc: add boundary check for mmc operation


Signed-off-by: default avatarLei Wen <leiwen@marvell.com>
parent a12555c0
No related branches found
No related tags found
No related merge requests found
...@@ -92,6 +92,11 @@ mmc_bwrite(int dev_num, ulong start, lbaint_t blkcnt, const void*src) ...@@ -92,6 +92,11 @@ mmc_bwrite(int dev_num, ulong start, lbaint_t blkcnt, const void*src)
blklen = mmc->write_bl_len; blklen = mmc->write_bl_len;
if ((start + blkcnt) > mmc->block_dev.lba) {
printf("MMC: block number 0x%x exceeds max(0x%x)",
start + blkcnt, mmc->block_dev.lba);
return 0;
}
err = mmc_set_blocklen(mmc, mmc->write_bl_len); err = mmc_set_blocklen(mmc, mmc->write_bl_len);
if (err) { if (err) {
...@@ -219,6 +224,11 @@ static ulong mmc_bread(int dev_num, ulong start, lbaint_t blkcnt, void *dst) ...@@ -219,6 +224,11 @@ static ulong mmc_bread(int dev_num, ulong start, lbaint_t blkcnt, void *dst)
if (!mmc) if (!mmc)
return 0; return 0;
if ((start + blkcnt) > mmc->block_dev.lba) {
printf("MMC: block number 0x%x exceeds max(0x%x)",
start + blkcnt, mmc->block_dev.lba);
return 0;
}
/* We always do full block reads from the card */ /* We always do full block reads from the card */
err = mmc_set_blocklen(mmc, mmc->read_bl_len); err = mmc_set_blocklen(mmc, mmc->read_bl_len);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment