summaryrefslogtreecommitdiff
path: root/drivers/dfu
diff options
context:
space:
mode:
authorPrzemyslaw Marczak <p.marczak@samsung.com>2014-12-15 10:34:09 +0100
committerLukasz Majewski <l.majewski@samsung.com>2014-12-18 12:26:06 +0100
commit7da6fa27168c468e58814d54fe3f66109036ec2e (patch)
tree17b26df37857b10b0da0971dabdeca166cf4caf2 /drivers/dfu
parent267abc626da609560aecab83e06b187954974ba6 (diff)
downloadu-boot-7da6fa27168c468e58814d54fe3f66109036ec2e.tar.gz
dfu: mmc: check if mmc device exists in mmc_block_op()
The function mmc_block_op() is the last function before the physicall data write, but the mmc device pointer is not checked. If mmc device not exists, then data abort will occur. To avoid this, first the mmc device pointer is checked. Signed-off-by: Przemyslaw Marczak <p.marczak@samsung.com> Tested-by: Lukasz Majewski <l.majewski@samsung.com> [TestHW: Exynos4412-Trats2]
Diffstat (limited to 'drivers/dfu')
-rw-r--r--drivers/dfu/dfu_mmc.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/drivers/dfu/dfu_mmc.c b/drivers/dfu/dfu_mmc.c
index 72fa03eeda..62d72fe4c6 100644
--- a/drivers/dfu/dfu_mmc.c
+++ b/drivers/dfu/dfu_mmc.c
@@ -40,10 +40,16 @@ static int mmc_access_part(struct dfu_entity *dfu, struct mmc *mmc, int part)
static int mmc_block_op(enum dfu_op op, struct dfu_entity *dfu,
u64 offset, void *buf, long *len)
{
- struct mmc *mmc = find_mmc_device(dfu->data.mmc.dev_num);
+ struct mmc *mmc;
u32 blk_start, blk_count, n = 0;
int ret, part_num_bkp = 0;
+ mmc = find_mmc_device(dfu->data.mmc.dev_num);
+ if (!mmc) {
+ error("Device MMC %d - not found!", dfu->data.mmc.dev_num);
+ return -ENODEV;
+ }
+
/*
* We must ensure that we work in lba_blk_size chunks, so ALIGN
* this value.