free memory correctly in case of an error. Fixes CID 131540 and CID 1315419
Этот коммит содержится в:
родитель
0aa3049bfc
Коммит
1293d9c69b
@ -60,6 +60,7 @@ int mca_sharedfp_individual_file_open (struct ompi_communicator_t *comm,
|
||||
if ( NULL == sh ){
|
||||
opal_output(0, "mca_sharedfp_individual_file_open: Error, unable to malloc "
|
||||
"f_sharedfp_ptr struct\n");
|
||||
free (shfileHandle );
|
||||
return OMPI_ERR_OUT_OF_RESOURCE;
|
||||
}
|
||||
|
||||
@ -94,6 +95,8 @@ int mca_sharedfp_individual_file_open (struct ompi_communicator_t *comm,
|
||||
MPI_INFO_NULL, datafilehandle, false);
|
||||
if ( OMPI_SUCCESS != err) {
|
||||
opal_output(0, "mca_sharedfp_individual_file_open: Error during datafile file open\n");
|
||||
free (shfileHandle );
|
||||
free (sh);
|
||||
return err;
|
||||
}
|
||||
|
||||
@ -107,14 +110,31 @@ int mca_sharedfp_individual_file_open (struct ompi_communicator_t *comm,
|
||||
|
||||
/* metadata filename created by appending .metadata.$rank to the original filename*/
|
||||
metadatafilename = (char*) malloc ( len );
|
||||
if ( NULL == metadatafilename ) {
|
||||
free (shfileHandle );
|
||||
free (sh);
|
||||
opal_output(0, "mca_sharedfp_individual_file_open: Error during memory allocation\n");
|
||||
return OMPI_ERR_OUT_OF_RESOURCE;
|
||||
}
|
||||
snprintf ( metadatafilename, len, "%s%s%d", filename, ".metadata.",rank);
|
||||
|
||||
metadatafilehandle = (mca_io_ompio_file_t *)malloc(sizeof(mca_io_ompio_file_t));
|
||||
if ( NULL == metadatafilehandle ) {
|
||||
free (shfileHandle );
|
||||
free (sh);
|
||||
free (metadatafilename);
|
||||
opal_output(0, "mca_sharedfp_individual_file_open: Error during memory allocation\n");
|
||||
return OMPI_ERR_OUT_OF_RESOURCE;
|
||||
}
|
||||
err = ompio_io_ompio_file_open ( MPI_COMM_SELF,metadatafilename,
|
||||
MPI_MODE_RDWR | MPI_MODE_CREATE | MPI_MODE_DELETE_ON_CLOSE,
|
||||
MPI_INFO_NULL, metadatafilehandle, false);
|
||||
if ( OMPI_SUCCESS != err) {
|
||||
opal_output(0, "mca_sharedfp_individual_file_open: Error during metadatafile file open\n");
|
||||
free (shfileHandle );
|
||||
free (sh);
|
||||
free (metadatafilename);
|
||||
free (metadatafilehandle);
|
||||
return err;
|
||||
}
|
||||
|
||||
|
@ -61,6 +61,7 @@ int mca_sharedfp_lockedfile_file_open (struct ompi_communicator_t *comm,
|
||||
sh = (struct mca_sharedfp_base_data_t*)malloc(sizeof(struct mca_sharedfp_base_data_t));
|
||||
if ( NULL == sh){
|
||||
opal_output(0, "mca_sharedfp_lockedfile_file_open: Error, unable to malloc f_sharedfp_ptr struct\n");
|
||||
free ( shfileHandle);
|
||||
return OMPI_ERR_OUT_OF_RESOURCE;
|
||||
}
|
||||
/*Populate the sh file structure based on the implementation*/
|
||||
@ -80,6 +81,8 @@ int mca_sharedfp_lockedfile_file_open (struct ompi_communicator_t *comm,
|
||||
module_data = (struct mca_sharedfp_lockedfile_data*)malloc(sizeof(struct mca_sharedfp_lockedfile_data));
|
||||
if ( NULL == module_data ) {
|
||||
printf("mca_sharedfp_lockedfile_file_open: Error, unable to malloc lockedfile_data struct\n");
|
||||
free (shfileHandle);
|
||||
free (sh);
|
||||
return OMPI_ERR_OUT_OF_RESOURCE;
|
||||
}
|
||||
|
||||
@ -104,6 +107,8 @@ int mca_sharedfp_lockedfile_file_open (struct ompi_communicator_t *comm,
|
||||
handle = open ( lockedfilename, O_RDWR, 0644 );
|
||||
if ( -1 == handle ) {
|
||||
printf("[%d]mca_sharedfp_lockedfile_file_open: Error during file open\n", rank);
|
||||
free (shfileHandle);
|
||||
free (sh);
|
||||
free(module_data);
|
||||
return OMPI_ERROR;
|
||||
}
|
||||
|
@ -64,9 +64,14 @@ int mca_sharedfp_sm_file_open (struct ompi_communicator_t *comm,
|
||||
/*Open the same file again without shared file pointer*/
|
||||
/*----------------------------------------------------*/
|
||||
shfileHandle = (mca_io_ompio_file_t *)malloc(sizeof(mca_io_ompio_file_t));
|
||||
if ( NULL == shfileHandle ) {
|
||||
opal_output(0, "mca_sharedfp_sm_file_open: Error during memory allocation\n");
|
||||
return OMPI_ERR_OUT_OF_RESOURCE;
|
||||
}
|
||||
err = ompio_io_ompio_file_open(comm,filename,amode,info,shfileHandle,false);
|
||||
if ( OMPI_SUCCESS != err) {
|
||||
opal_output(0, "mca_sharedfp_sm_file_open: Error during file open\n");
|
||||
free (shfileHandle);
|
||||
return err;
|
||||
}
|
||||
shfileHandle->f_fh = fh->f_fh;
|
||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user