arm_adi_v5: check for calloc() return value
In function adiv5_jim_configure() check that calloc() returns a valid allocated memory pointer. Change-Id: I97287e168834693900341add9d9eb9a5f38c55b4 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reported-by: Tomas Vanek <vanekt@fbl.cz> Reviewed-on: https://review.openocd.org/c/openocd/+/7014 Tested-by: jenkins Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
This commit is contained in:
parent
54f0cab18e
commit
7cc79a8d62
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue