Skip to content

Commit 2ed4501

Browse files
committed
osc: fix coverity issues
Fix CID 1324726 (#1 of 1): Free of address-of expression (BAD_FREE): Indeed, if a lock conflicts with the lock_all we will end up trying to free an invalid pointer. Fix CID 1328826 (#1 of 1): Dereference after null check (FORWARD_NULL): This was intentional but it would be a good idea to check for module->comm being non_NULL to be safe. Also cleaned out some checks for NULL before free(). Signed-off-by: Nathan Hjelm <[email protected]>
1 parent 013aec8 commit 2ed4501

File tree

2 files changed

+8
-13
lines changed

2 files changed

+8
-13
lines changed

ompi/mca/osc/pt2pt/osc_pt2pt_passive_target.c

+3-1
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,9 @@ static int ompi_osc_pt2pt_lock_internal (int lock_type, int target, int assert,
320320

321321
/* check for conflicting lock */
322322
if (ompi_osc_pt2pt_module_lock_find (module, target, NULL)) {
323-
ompi_osc_pt2pt_sync_return (lock);
323+
if (&module->all_sync != lock) {
324+
ompi_osc_pt2pt_sync_return (lock);
325+
}
324326
OPAL_THREAD_UNLOCK(&module->lock);
325327
return OMPI_ERR_RMA_CONFLICT;
326328
}

ompi/mca/osc/rdma/osc_rdma_module.c

+5-12
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* University of Stuttgart. All rights reserved.
99
* Copyright (c) 2004-2005 The Regents of the University of California.
1010
* All rights reserved.
11-
* Copyright (c) 2007-2015 Los Alamos National Security, LLC. All rights
11+
* Copyright (c) 2007-2016 Los Alamos National Security, LLC. All rights
1212
* reserved.
1313
* Copyright (c) 2012-2013 Sandia National Laboratories. All rights reserved.
1414
* $COPYRIGHT$
@@ -103,18 +103,12 @@ int ompi_osc_rdma_free(ompi_win_t *win)
103103
}
104104

105105
OBJ_DESTRUCT(&module->peer_hash);
106-
} else {
106+
} else if (NULL != module->comm) {
107107
for (int i = 0 ; i < ompi_comm_rank (module->comm) ; ++i) {
108108
if (NULL != module->peer_array[i]) {
109109
OBJ_RELEASE(module->peer_array[i]);
110110
}
111111
}
112-
113-
free (module->peer_array);
114-
}
115-
116-
if (NULL != module->outstanding_lock_array) {
117-
free (module->outstanding_lock_array);
118112
}
119113

120114
if (module->local_leaders && MPI_COMM_NULL != module->local_leaders) {
@@ -129,15 +123,14 @@ int ompi_osc_rdma_free(ompi_win_t *win)
129123
ompi_comm_free (&module->comm);
130124
}
131125

132-
if (NULL != module->free_after) {
133-
free(module->free_after);
134-
}
135-
136126
if (module->segment_base) {
137127
opal_shmem_segment_detach (&module->seg_ds);
138128
module->segment_base = NULL;
139129
}
140130

131+
free (module->peer_array);
132+
free (module->outstanding_lock_array);
133+
free (module->free_after);
141134
free (module);
142135

143136
return OMPI_SUCCESS;

0 commit comments

Comments
 (0)