Skip to content

Fix memory leak if critnib_new fails #532

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 7 additions & 9 deletions src/provider/provider_os_memory.c
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,13 @@ static umf_result_t os_initialize(void *params, void **provider) {
goto err_destroy_hwloc_topology;
}

os_provider->fd_offset_map = critnib_new();
if (!os_provider->fd_offset_map) {
LOG_ERR("creating file descriptor offset map failed");
ret = UMF_RESULT_ERROR_OUT_OF_HOST_MEMORY;
goto err_destroy_hwloc_topology;
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what will happen now, the other way around, if e.g. translate_params fail. Shouldn't we call critnib_delete...?

ret = translate_params(in_params, os_provider);
if (ret != UMF_RESULT_SUCCESS) {
goto err_destroy_hwloc_topology;
Expand All @@ -350,19 +357,10 @@ static umf_result_t os_initialize(void *params, void **provider) {
}
}

os_provider->fd_offset_map = critnib_new();
if (!os_provider->fd_offset_map) {
LOG_ERR("creating file descriptor offset map failed");
ret = UMF_RESULT_ERROR_OUT_OF_HOST_MEMORY;
goto err_free_nodeset_str_buf;
}

*provider = os_provider;

return UMF_RESULT_SUCCESS;

err_free_nodeset_str_buf:
umf_ba_global_free(os_provider->nodeset_str_buf);
err_destroy_hwloc_topology:
hwloc_topology_destroy(os_provider->topo);
err_free_os_provider:
Expand Down