diff options
author | Ye Li <ye.li@nxp.com> | 2018-11-12 03:51:23 -0800 |
---|---|---|
committer | Ye Li <ye.li@nxp.com> | 2018-11-12 20:09:51 -0800 |
commit | f85da6b1fca7a8e6a8e0795aa38dfb9bde7a5e2d (patch) | |
tree | cfa9a2618d5af6b5549a26496412fd7ab76864c3 /drivers | |
parent | 661bc6ec62d462dc7380243f5f45d89442c849d8 (diff) |
MLK-20240-8 fastboot: Add NULL check for mmc variable
Fix coverity issue CID 5015449: Dereference before null check (REVERSE_INULL)
check_after_deref: Null-checking mmc suggests that it may be null, but it has
already been dereferenced on all paths leading to the check
Signed-off-by: Ye Li <ye.li@nxp.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/usb/gadget/f_fastboot.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/drivers/usb/gadget/f_fastboot.c b/drivers/usb/gadget/f_fastboot.c index be9c68a146..bad99accc8 100644 --- a/drivers/usb/gadget/f_fastboot.c +++ b/drivers/usb/gadget/f_fastboot.c @@ -1380,9 +1380,14 @@ static int _fastboot_parts_load_from_ptable(void) printf("flash target is MMC:%d\n", mmc_no); mmc = find_mmc_device(mmc_no); + if (mmc == NULL) { + printf("invalid mmc device %d\n", mmc_no); + return -1; + } + /* Force to init mmc */ mmc->has_init = 0; - if (mmc && mmc_init(mmc)) + if (mmc_init(mmc)) printf("MMC card init failed!\n"); dev_desc = blk_get_dev("mmc", mmc_no); |