diff options
Diffstat (limited to 'common')
-rw-r--r-- | common/Kconfig | 1 | ||||
-rw-r--r-- | common/avb_verify.c | 22 | ||||
-rw-r--r-- | common/malloc_simple.c | 3 |
3 files changed, 17 insertions, 9 deletions
diff --git a/common/Kconfig b/common/Kconfig index b3d9b37463..3030da4fc9 100644 --- a/common/Kconfig +++ b/common/Kconfig @@ -647,6 +647,7 @@ config HASH config AVB_VERIFY bool "Build Android Verified Boot operations" depends on LIBAVB && FASTBOOT + depends on PARTITION_UUIDS help This option enables compilation of bootloader-dependent operations, used by Android Verified Boot 2.0 library (libavb). Includes: 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; diff --git a/common/malloc_simple.c b/common/malloc_simple.c index c14f8b59c1..871b5444bd 100644 --- a/common/malloc_simple.c +++ b/common/malloc_simple.c @@ -57,7 +57,8 @@ void *calloc(size_t nmemb, size_t elem_size) void *ptr; ptr = malloc(size); - memset(ptr, '\0', size); + if (ptr) + memset(ptr, '\0', size); return ptr; } |