Примеры ошибок, обнаруженных с помощью диагностики V1020
V1020. Function exited without performing epilogue actions. It is possible that there is an error.
Zephyr
V1020 The function exited without calling the 'k_mutex_unlock' function. Check lines: 620, 549. nvs.c 620
static int nvs_startup(struct nvs_fs *fs)
{
....
k_mutex_lock(&fs->nvs_lock, K_FOREVER);
....
if (fs->ate_wra == fs->data_wra && last_ate.len) {
return -ESPIPE;
}
....
end:
k_mutex_unlock(&fs->nvs_lock);
return rc;
}
Similar errors can be found in some other places:
- V1020 The function exited without calling the 'k_mutex_unlock' function. Check lines: 574, 549. nvs.c 574
- V1020 The function exited without calling the 'k_mutex_unlock' function. Check lines: 908, 890. net_context.c 908
- V1020 The function exited without calling the 'k_mutex_unlock' function. Check lines: 1194, 1189. shell.c 1194
iSulad
V1020 [CWE-772] The function exited without calling the 'mutex_unlock' function. Check lines: 502, 495. local.c 502
struct volumes *local_volume_list(void)
{
int ret = 0;
map_itor *itor = NULL;
struct volume *vol = NULL;
struct volume *v = NULL;
struct volumes *vols = NULL;
size_t size = 0;
mutex_lock(&g_volumes->mutex);
size = map_size(g_volumes->vols_by_name);
vols = new_empty_volumes(size);
if (vols == NULL) {
ERROR("out of memory");
return NULL;
}
itor = map_itor_new(g_volumes->vols_by_name);
if (itor == NULL) {
ERROR("failed to get volumes's iterator to get all volumes");
ret = -1;
goto out;
}
....
out:
map_itor_free(itor);
mutex_unlock(&g_volumes->mutex);
if (ret != 0) {
free_volumes(vols);
vols = NULL;
}
return vols;
}