Skip to content

Commit 4bbd6dc

Browse files
authored
Merge pull request open-mpi#13402 from hppritcha/coverity_cid_1665460
CID 1665460 fix and more
2 parents 960bb2a + ab0b590 commit 4bbd6dc

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

ompi/mca/pml/base/pml_base_bsend.c

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -146,12 +146,12 @@ static void* mca_pml_bsend_alloc_segment(void *ctx, size_t *size_inout)
146146
static void* mca_pml_bsend_alloc_seg_auto(void *ctx, size_t *size_inout)
147147
{
148148
void *addr;
149-
const uint64_t seg_size = (1024UL * 1024UL);
149+
size_t size = *size_inout;
150150

151-
addr = malloc(seg_size);
152-
if (NULL != addr);
153-
154-
*size_inout += seg_size;
151+
addr = malloc(size);
152+
if (NULL != addr) {
153+
*size_inout = size;
154+
}
155155
return addr;
156156
}
157157

@@ -705,6 +705,9 @@ int mca_pml_base_bsend_request_free(ompi_communicator_t *comm, void* addr)
705705
int mca_pml_base_bsend_request_fini(ompi_request_t* request)
706706
{
707707
mca_pml_bsend_buffer_t *buffer = mca_pml_bsend_buffer_get(request->req_mpi_object.comm);
708+
if(NULL == buffer) {
709+
return OMPI_ERR_BUFFER;
710+
}
708711

709712
mca_pml_base_send_request_t* sendreq = (mca_pml_base_send_request_t*)request;
710713
if(sendreq->req_bytes_packed == 0 ||
@@ -715,7 +718,7 @@ int mca_pml_base_bsend_request_fini(ompi_request_t* request)
715718
/* remove from list of pending requests */
716719
OPAL_THREAD_LOCK(&buffer->bsend_mutex);
717720

718-
/* free buffer */
721+
/* free the buffer memory associated with this request */
719722
buffer->bsend_allocator->alc_free(buffer->bsend_allocator, (void *)sendreq->req_addr);
720723
sendreq->req_addr = sendreq->req_base.req_addr;
721724

0 commit comments

Comments
 (0)