diff options
Diffstat (limited to 'common/avb_verify.c')
-rw-r--r-- | common/avb_verify.c | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/common/avb_verify.c b/common/avb_verify.c index 82ddebcfc2..f8c6ae5566 100644 --- a/common/avb_verify.c +++ b/common/avb_verify.c @@ -11,7 +11,7 @@ #include <malloc.h> #include <part.h> -const unsigned char avb_root_pub[1032] = { +static const unsigned char avb_root_pub[1032] = { 0x0, 0x0, 0x10, 0x0, 0x55, 0xd9, 0x4, 0xad, 0xd8, 0x4, 0xaf, 0xe3, 0xd3, 0x84, 0x6c, 0x7e, 0xd, 0x89, 0x3d, 0xc2, 0x8c, 0xd3, 0x12, 0x55, 0xe9, 0x62, 0xc9, 0xf1, 0xf, 0x5e, @@ -176,7 +176,7 @@ static int avb_find_dm_args(char **args, char *str) if (!str) return -1; - for (i = 0; i < AVB_MAX_ARGS, args[i]; ++i) { + for (i = 0; i < AVB_MAX_ARGS && args[i]; ++i) { if (strstr(args[i], str)) return i; } @@ -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, @@ -399,6 +402,9 @@ static AvbIOResult mmc_byte_io(AvbOps *ops, if (!part) return AVB_IO_RESULT_ERROR_NO_SUCH_PARTITION; + if (!part->info.blksz) + return AVB_IO_RESULT_ERROR_IO; + start_offset = calc_offset(part, offset); while (num_bytes) { start_sector = start_offset / part->info.blksz; @@ -763,7 +769,7 @@ void avb_ops_free(AvbOps *ops) { struct AvbOpsData *ops_data; - if (ops) + if (!ops) return; ops_data = ops->user_data; |