Skip to content

Commit

Permalink
arm_adi_v5: check for calloc() return value
Browse files Browse the repository at this point in the history
In function adiv5_jim_configure() check that calloc() returns a
valid allocated memory pointer.

Change-Id: I97287e168834693900341add9d9eb9a5f38c55b4
Signed-off-by: Antonio Borneo <[email protected]>
Reported-by: Tomas Vanek <[email protected]>
Reviewed-on: https://review.openocd.org/c/openocd/+/7014
Tested-by: jenkins
Reviewed-by: Tomas Vanek <[email protected]>
  • Loading branch information
borneoa committed Jun 10, 2022
1 parent 54f0cab commit 7cc79a8
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/target/arm_adi_v5.c
Original file line number Diff line number Diff line change
Expand Up @@ -2044,6 +2044,10 @@ int adiv5_jim_configure(struct target *target, struct jim_getopt_info *goi)
pc = (struct adiv5_private_config *)target->private_config;
if (!pc) {
pc = calloc(1, sizeof(struct adiv5_private_config));
if (!pc) {
LOG_ERROR("Out of memory");
return JIM_ERR;
}
pc->ap_num = DP_APSEL_INVALID;
target->private_config = pc;
}
Expand Down

0 comments on commit 7cc79a8

Please sign in to comment.