]> git.kernelconcepts.de Git - karo-tx-uboot.git/blobdiff - drivers/dfu/dfu_mmc.c
dfu: mmc: check if mmc device exists in mmc_block_op()
[karo-tx-uboot.git] / drivers / dfu / dfu_mmc.c
index 72fa03eedaecd3700fea7d4ed4e277fad2112ce5..62d72fe4c69a3843974a353f28885fd8661c640e 100644 (file)
@@ -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.