public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] [PATCH 1/2] mmc: add boundary check for mmc operation
@ 2010-09-13  9:17 Lei Wen
  2010-09-13  9:17 ` [U-Boot] [PATCH 2/2] mmc: print out avaible partition table Lei Wen
                   ` (3 more replies)
  0 siblings, 4 replies; 20+ messages in thread
From: Lei Wen @ 2010-09-13  9:17 UTC (permalink / raw)
  To: u-boot

Signed-off-by: Lei Wen <leiwen@marvell.com>
---
 drivers/mmc/mmc.c |   10 ++++++++++
 1 files changed, 10 insertions(+), 0 deletions(-)

diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c
index cf4ea16..42638f6 100644
--- a/drivers/mmc/mmc.c
+++ b/drivers/mmc/mmc.c
@@ -92,6 +92,11 @@ mmc_bwrite(int dev_num, ulong start, lbaint_t blkcnt, const void*src)
 
 	blklen = mmc->write_bl_len;
 
+	if ((start + blkcnt) > mmc->block_dev.lba) {
+		puts("operation exceed mmc boundary..\n"
+		     "This devices only have 0x%x blocks\n", mmc->block_dev.lba);
+		return 0;
+	}
 	err = mmc_set_blocklen(mmc, mmc->write_bl_len);
 
 	if (err) {
@@ -219,6 +224,11 @@ static ulong mmc_bread(int dev_num, ulong start, lbaint_t blkcnt, void *dst)
 	if (!mmc)
 		return 0;
 
+	if ((start + blkcnt) > mmc->block_dev.lba) {
+		puts("operation exceed mmc boundary..\n"
+		     "This devices only have 0x%x blocks\n", mmc->block_dev.lba);
+		return 0;
+	}
 	/* We always do full block reads from the card */
 	err = mmc_set_blocklen(mmc, mmc->read_bl_len);
 
-- 
1.7.0.4

^ permalink raw reply related	[flat|nested] 20+ messages in thread

end of thread, other threads:[~2010-10-12 19:48 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-09-13  9:17 [U-Boot] [PATCH 1/2] mmc: add boundary check for mmc operation Lei Wen
2010-09-13  9:17 ` [U-Boot] [PATCH 2/2] mmc: print out avaible partition table Lei Wen
2010-09-13  9:47 ` [U-Boot] [PATCH 1/2] mmc: add boundary check for mmc operation Wolfgang Denk
2010-09-13 11:54 ` [U-Boot] [PATCH 1/2 V2] " Lei Wen
2010-09-13 13:40   ` Sergei Shtylyov
2010-09-13 14:03     ` Lei Wen
2010-09-13 11:54 ` [U-Boot] [PATCH 2/2 V2] mmc: print out avaible partition table Lei Wen
2010-09-13 13:41   ` Sergei Shtylyov
2010-09-13 14:03     ` Lei Wen
2010-09-13 14:07     ` [U-Boot] [PATCH 1/2 V3] mmc: add boundary check for mmc operation Lei Wen
2010-09-17  3:22       ` Lei Wen
2010-09-18 13:01         ` Lei Wen
2010-09-18 21:46       ` Wolfgang Denk
2010-09-20 10:39         ` Ghorai, Sukumar
2010-09-20 12:59           ` Lei Wen
2010-09-20 13:28             ` Ghorai, Sukumar
2010-10-12 19:20               ` Wolfgang Denk
2010-10-12 19:48                 ` Ghorai, Sukumar
2010-09-13 14:07     ` [U-Boot] [PATCH 2/2 V3] mmc: print out avaible partition table Lei Wen
2010-09-18 21:47       ` Wolfgang Denk

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox