summaryrefslogtreecommitdiff
path: root/common/cmd_mmc.c
diff options
context:
space:
mode:
authorRabin Vincent <rabin@rab.in>2009-04-05 13:30:53 +0530
committerAndy Fleming <afleming@freescale.com>2009-06-02 17:18:56 -0500
commite85649c7e683faea1ccfddc9fa9abc62f38e4201 (patch)
treeee1f5c96aba8a19b2567d0f542e787f81a1f13f1 /common/cmd_mmc.c
parentac0865ff33870cdf2cd480165045e1bc311e9fa2 (diff)
mmc: check find_mmc_device return value
find_mmc_device returns NULL if an invalid device number is specified. Check for this to avoid dereferencing NULL pointers. Signed-off-by: Rabin Vincent <rabin@rab.in>
Diffstat (limited to 'common/cmd_mmc.c')
-rw-r--r--common/cmd_mmc.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/common/cmd_mmc.c b/common/cmd_mmc.c
index bd55ff1c77..039fe59c75 100644
--- a/common/cmd_mmc.c
+++ b/common/cmd_mmc.c
@@ -149,6 +149,9 @@ int do_mmcops(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
int dev = simple_strtoul(argv[2], NULL, 10);
struct mmc *mmc = find_mmc_device(dev);
+ if (!mmc)
+ return 1;
+
mmc_init(mmc);
return 0;
@@ -175,6 +178,9 @@ int do_mmcops(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
u32 blk = simple_strtoul(argv[4], NULL, 16);
struct mmc *mmc = find_mmc_device(dev);
+ if (!mmc)
+ return 1;
+
printf("\nMMC read: dev # %d, block # %d, count %d ... ",
dev, blk, cnt);
@@ -197,6 +203,9 @@ int do_mmcops(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
int blk = simple_strtoul(argv[4], NULL, 16);
+ if (!mmc)
+ return 1;
+
printf("\nMMC write: dev # %d, block # %d, count %d ... ",
dev, blk, cnt);