diff options
author | Eugeniu Rosca <roscaeugeniu@gmail.com> | 2018-08-14 02:43:07 +0200 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2018-08-24 13:19:53 -0400 |
commit | 047bc5c75503105bf8ee66db793d9d249c281521 (patch) | |
tree | dece079a0b214f7cf8fd45544a21ae2cbc14f950 /common/avb_verify.c | |
parent | 55d56d23479c57e530abbcc82459ca641d2ce7d8 (diff) | |
download | u-boot-047bc5c75503105bf8ee66db793d9d249c281521.zip u-boot-047bc5c75503105bf8ee66db793d9d249c281521.tar.gz u-boot-047bc5c75503105bf8ee66db793d9d249c281521.tar.bz2 |
common: avb_verify: Fix memory leaks
Cppcheck (v1.85) reports w/o this patch:
[common/avb_verify.c:351]: (error) Memory leak: part
[common/avb_verify.c:356]: (error) Memory leak: part
[common/avb_verify.c:361]: (error) Memory leak: part
[common/avb_verify.c:366]: (error) Memory leak: part
Signed-off-by: Eugeniu Rosca <erosca@de.adit-jv.com>
Reviewed-by: Igor Opaniuk <igor.opaniuk@linaro.org>
Diffstat (limited to 'common/avb_verify.c')
-rw-r--r-- | common/avb_verify.c | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/common/avb_verify.c b/common/avb_verify.c index 5563250..0bc1c23 100644 --- a/common/avb_verify.c +++ b/common/avb_verify.c @@ -348,34 +348,37 @@ static struct mmc_part *get_partition(AvbOps *ops, const char *partition) part->mmc = find_mmc_device(dev_num); if (!part->mmc) { printf("No MMC device at slot %x\n", dev_num); - return NULL; + goto err; } if (mmc_init(part->mmc)) { printf("MMC initialization failed\n"); - return NULL; + goto err; } ret = mmc_switch_part(part->mmc, part_num); if (ret) - return NULL; + goto err; mmc_blk = mmc_get_blk_desc(part->mmc); if (!mmc_blk) { printf("Error - failed to obtain block descriptor\n"); - return NULL; + goto err; } ret = part_get_info_by_name(mmc_blk, partition, &part->info); if (!ret) { printf("Can't find partition '%s'\n", partition); - return NULL; + goto err; } part->dev_num = dev_num; part->mmc_blk = mmc_blk; return part; +err: + free(part); + return NULL; } static AvbIOResult mmc_byte_io(AvbOps *ops, |