aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTomas Vanek <vanekt@fbl.cz>2019-12-20 23:50:26 +0100
committerTomas Vanek <vanekt@fbl.cz>2020-01-16 09:46:27 +0000
commitaf0dda82666e1e4f241fabc0db62212d51413a08 (patch)
treed1fffa741f11f442756fd7ed6f744418bbd0b400 /src
parentfe6bb7eac8c7028236306c562d24a25ef79d0c15 (diff)
target/etm: add check for calloc error
and fix one more clang static analyzer warning. Change-Id: I17f03e318e1cf7617e7f753e7ca960552be547e5 Signed-off-by: Tomas Vanek <vanekt@fbl.cz> Reviewed-on: http://openocd.zylin.com/5381 Tested-by: jenkins Reviewed-by: Oleksij Rempel <linux@rempel-privat.de>
Diffstat (limited to 'src')
-rw-r--r--src/target/etm.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/target/etm.c b/src/target/etm.c
index 5751348e..d1cfe61f 100644
--- a/src/target/etm.c
+++ b/src/target/etm.c
@@ -303,6 +303,11 @@ struct reg_cache *etm_build_reg_cache(struct target *target,
reg_list = calloc(128, sizeof(struct reg));
arch_info = calloc(128, sizeof(struct etm_reg));
+ if (reg_cache == NULL || reg_list == NULL || arch_info == NULL) {
+ LOG_ERROR("No memory");
+ goto fail;
+ }
+
/* fill in values for the reg cache */
reg_cache->name = "etm registers";
reg_cache->next = NULL;
@@ -498,6 +503,7 @@ static int etm_read_reg_w_check(struct reg *reg,
uint8_t *check_value, uint8_t *check_mask)
{
struct etm_reg *etm_reg = reg->arch_info;
+ assert(etm_reg);
const struct etm_reg_info *r = etm_reg->reg_info;
uint8_t reg_addr = r->addr & 0x7f;
struct scan_field fields[3];