platform: check calloc result

This commit is contained in:
Rafael Silva 2022-08-05 22:30:43 +01:00 committed by Rachel Mant
parent 81890b1fe9
commit a1f0d28913
1 changed files with 7 additions and 1 deletions

View File

@ -136,7 +136,13 @@ int platform_adiv5_swdp_scan(uint32_t targetid)
case BMP_TYPE_STLINKV2:
{
target_list_free();
ADIv5_DP_t *dp = (void*)calloc(1, sizeof(*dp));
ADIv5_DP_t *dp = calloc(1, sizeof(*dp));
if (!dp) { /* calloc failed: heap exhaustion */
DEBUG_WARN("calloc: failed in %s\n", __func__);
return 0;
}
if (stlink_enter_debug_swd(&info, dp)) {
free(dp);
} else {