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>
This commit is contained in:
Rabin Vincent
2009-04-05 13:30:53 +05:30
committed by Andy Fleming
parent ac0865ff33
commit e85649c7e6
2 changed files with 10 additions and 1 deletions

View File

@@ -846,7 +846,7 @@ block_dev_desc_t *mmc_get_dev(int dev)
{
struct mmc *mmc = find_mmc_device(dev);
return &mmc->block_dev;
return mmc ? &mmc->block_dev : NULL;
}
int mmc_init(struct mmc *mmc)