1
1

fbtl/posix: fix misc memory leaks

as reported by Coverity with CIDs 72125, 72126, 1269899 and 1269900
Этот коммит содержится в:
Gilles Gouaillardet 2015-03-03 14:38:34 +09:00
родитель 838cd51644
Коммит 9f13425980
4 изменённых файлов: 33 добавлений и 17 удалений

Просмотреть файл

@ -10,6 +10,8 @@
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* Copyright (c) 2008-2015 University of Houston. All rights reserved.
* Copyright (c) 2015 Research Organization for Information Science
* and Technology (RIST). All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
@ -54,12 +56,15 @@ ssize_t mca_fbtl_posix_ipreadv (mca_io_ompio_file_t *fh,
fh->f_num_of_io_entries);
if (NULL == data->aio_reqs) {
opal_output(1, "OUT OF MEMORY\n");
free(data);
return 0;
}
data->aio_req_status = (int *) malloc (sizeof(int) * fh->f_num_of_io_entries);
if (NULL == data->aio_req_status) {
opal_output(1, "OUT OF MEMORY\n");
free(data->aio_reqs);
free(data);
return 0;
}
@ -83,7 +88,10 @@ ssize_t mca_fbtl_posix_ipreadv (mca_io_ompio_file_t *fh,
}
for (i=0; i < data->aio_last_active_req; i++) {
if (-1 == aio_read(&data->aio_reqs[i])) {
perror("aio_read() error");
opal_output(1, "aio_read() error: %s", strerror(errno));
free(data->aio_reqs);
free(data->aio_req_status);
free(data);
return OMPI_ERROR;
}
}

Просмотреть файл

@ -10,6 +10,8 @@
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* Copyright (c) 2008-2015 University of Houston. All rights reserved.
* Copyright (c) 2015 Research Organization for Information Science
* and Technology (RIST). All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
@ -53,12 +55,15 @@ ssize_t mca_fbtl_posix_ipwritev (mca_io_ompio_file_t *fh,
fh->f_num_of_io_entries);
if (NULL == data->aio_reqs) {
opal_output(1, "OUT OF MEMORY\n");
free(data);
return 0;
}
data->aio_req_status = (int *) malloc (sizeof(int) * fh->f_num_of_io_entries);
if (NULL == data->aio_req_status) {
opal_output(1, "OUT OF MEMORY\n");
free(data->aio_reqs);
free(data);
return 0;
}
@ -83,7 +88,10 @@ ssize_t mca_fbtl_posix_ipwritev (mca_io_ompio_file_t *fh,
for (i=0; i < data->aio_last_active_req; i++) {
if (-1 == aio_write(&data->aio_reqs[i])) {
perror("aio_write() error");
opal_output(1, "aio_write() error: %s", strerror(errno));
free(data->aio_req_status);
free(data->aio_reqs);
free(data);
return OMPI_ERROR;
}
}

Просмотреть файл

@ -10,6 +10,8 @@
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* Copyright (c) 2008-2014 University of Houston. All rights reserved.
* Copyright (c) 2015 Research Organization for Information Science
* and Technology (RIST). All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
@ -79,7 +81,8 @@ ssize_t mca_fbtl_posix_preadv (mca_io_ompio_file_t *fh )
}
if (-1 == lseek (fh->fd, iov_offset, SEEK_SET)) {
perror ("fseek");
opal_output(1, "lseek:%s", strerror(errno));
free(iov);
return OMPI_ERROR;
}
ret_code = readv (fh->fd, iov, iov_count);
@ -87,7 +90,8 @@ ssize_t mca_fbtl_posix_preadv (mca_io_ompio_file_t *fh )
bytes_read+=ret_code;
}
else if ( ret_code == -1 ) {
perror ("readv");
opal_output(1, "readv:%s", strerror(errno));
free(iov);
return OMPI_ERROR;
}
else if ( 0 == ret_code ){
@ -97,11 +101,7 @@ ssize_t mca_fbtl_posix_preadv (mca_io_ompio_file_t *fh )
iov_count = 0;
}
if (NULL != iov) {
free (iov);
iov = NULL;
}
free (iov);
return bytes_read;
}

Просмотреть файл

@ -10,6 +10,8 @@
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* Copyright (c) 2008-2014 University of Houston. All rights reserved.
* Copyright (c) 2015 Research Organization for Information Science
* and Technology (RIST). All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
@ -92,7 +94,8 @@ ssize_t mca_fbtl_posix_pwritev(mca_io_ompio_file_t *fh )
*/
if (-1 == lseek (fh->fd, iov_offset, SEEK_SET)) {
perror ("lseek");
opal_output(1, "lseek:%s", strerror(errno));
free(iov);
return OMPI_ERROR;
}
ret_code = writev (fh->fd, iov, iov_count);
@ -100,17 +103,14 @@ ssize_t mca_fbtl_posix_pwritev(mca_io_ompio_file_t *fh )
bytes_written += ret_code;
}
else if (-1 == ret_code ) {
perror ("writev");
goto exit;
opal_output(1, "writev:%s", strerror(errno));
free (iov);
return OMPI_ERROR;
}
iov_count = 0;
}
exit:
if (NULL != iov) {
free (iov);
iov = NULL;
}
free (iov);
return bytes_written;
}