sharedfp/sm: fix misc memory leaks
as reported by Coverity with CIDs 1196785, 1196787 and 1269896
Этот коммит содержится в:
родитель
5b2122381b
Коммит
d6ae0a5e05
@ -11,6 +11,8 @@
|
|||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
* Copyright (c) 2013-2015 University of Houston. All rights reserved.
|
* Copyright (c) 2013-2015 University of Houston. All rights reserved.
|
||||||
* Copyright (c) 2013 Intel, Inc. All rights reserved.
|
* Copyright (c) 2013 Intel, Inc. All rights reserved.
|
||||||
|
* Copyright (c) 2015 Research Organization for Information Science
|
||||||
|
* and Technology (RIST). All rights reserved.
|
||||||
* $COPYRIGHT$
|
* $COPYRIGHT$
|
||||||
*
|
*
|
||||||
* Additional copyrights may follow
|
* Additional copyrights may follow
|
||||||
@ -113,6 +115,7 @@ int mca_sharedfp_sm_file_open (struct ompi_communicator_t *comm,
|
|||||||
filename_basename = basename(filename);
|
filename_basename = basename(filename);
|
||||||
sm_filename = (char*) malloc( sizeof(char) * (strlen(filename_basename)+64) );
|
sm_filename = (char*) malloc( sizeof(char) * (strlen(filename_basename)+64) );
|
||||||
if (NULL == sm_filename) {
|
if (NULL == sm_filename) {
|
||||||
|
free(sm_data);
|
||||||
free(sh);
|
free(sh);
|
||||||
free(shfileHandle);
|
free(shfileHandle);
|
||||||
return OMPI_ERR_OUT_OF_RESOURCE;
|
return OMPI_ERR_OUT_OF_RESOURCE;
|
||||||
@ -125,11 +128,14 @@ int mca_sharedfp_sm_file_open (struct ompi_communicator_t *comm,
|
|||||||
if ( sm_fd == -1){
|
if ( sm_fd == -1){
|
||||||
/*error opening file*/
|
/*error opening file*/
|
||||||
printf("mca_sharedfp_sm_file_open: Error, unable to open file for mmap: %s\n",sm_filename);
|
printf("mca_sharedfp_sm_file_open: Error, unable to open file for mmap: %s\n",sm_filename);
|
||||||
|
free(sm_filename);
|
||||||
|
free(sm_data);
|
||||||
free(sh);
|
free(sh);
|
||||||
free(shfileHandle);
|
free(shfileHandle);
|
||||||
return OMPI_ERROR;
|
return OMPI_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
free(sm_filename);
|
||||||
sm_data->sm_filename = sm_filename;
|
sm_data->sm_filename = sm_filename;
|
||||||
|
|
||||||
/*TODO: is it necessary to write to the file first?*/
|
/*TODO: is it necessary to write to the file first?*/
|
||||||
@ -149,6 +155,8 @@ int mca_sharedfp_sm_file_open (struct ompi_communicator_t *comm,
|
|||||||
err = OMPI_ERROR;
|
err = OMPI_ERROR;
|
||||||
printf("mca_sharedfp_sm_file_open: Error, unable to mmap file: %s\n",sm_filename);
|
printf("mca_sharedfp_sm_file_open: Error, unable to mmap file: %s\n",sm_filename);
|
||||||
printf("%s\n", strerror(errno));
|
printf("%s\n", strerror(errno));
|
||||||
|
free(sm_filename);
|
||||||
|
free(sm_data);
|
||||||
free(sh);
|
free(sh);
|
||||||
free(shfileHandle);
|
free(shfileHandle);
|
||||||
return OMPI_ERROR;
|
return OMPI_ERROR;
|
||||||
@ -188,9 +196,11 @@ int mca_sharedfp_sm_file_open (struct ompi_communicator_t *comm,
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
|
free(sm_filename);
|
||||||
free(sm_data);
|
free(sm_data);
|
||||||
free(sh);
|
free(sh);
|
||||||
free(shfileHandle);
|
free(shfileHandle);
|
||||||
|
munmap(sm_offset_ptr, sizeof(struct sm_offset));
|
||||||
err = OMPI_ERROR;
|
err = OMPI_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user