From: Lei Wen Date: Tue, 7 Sep 2010 20:32:08 +0800 Subject: [U-Boot] [PATCH 2/3] mmc: add boundary check for mmc operation In-Reply-To: <1283862729-17045-1-git-send-email-leiwen@marvell.com> References: <1283862729-17045-1-git-send-email-leiwen@marvell.com> Message-ID: <1283862729-17045-2-git-send-email-leiwen@marvell.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de Signed-off-by: Lei Wen --- drivers/mmc/mmc.c | 8 ++++++++ 1 files changed, 8 insertions(+), 0 deletions(-) diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c index 5cc1904..9a50b2f 100644 --- a/drivers/mmc/mmc.c +++ b/drivers/mmc/mmc.c @@ -134,6 +134,10 @@ mmc_bwrite(int dev_num, ulong start, lbaint_t blkcnt, const void*src) if (!mmc) return -1; + if (start > mmc->block_dev.lba || (start + blkcnt) > mmc->block_dev.lba) { + printf("\noperation excceed mmc boudary..\n"); + return 0; + } err = mmc_set_blocklen(mmc, mmc->write_bl_len); if (err) { printf("set write bl len failed\n\r"); @@ -236,6 +240,10 @@ static ulong mmc_bread(int dev_num, ulong start, lbaint_t blkcnt, void *dst) if (!mmc) return 0; + if (start > mmc->block_dev.lba || (start + blkcnt) > mmc->block_dev.lba) { + printf("\noperation excceed mmc boudary..\n"); + return 0; + } /* We always do full block reads from the card */ err = mmc_set_blocklen(mmc, mmc->read_bl_len); -- 1.7.0.4