@@ -133,8 +133,9 @@ static inline int ompi_osc_rdma_cas_local (const void *source_addr, const void *
133
133
ompi_osc_rdma_module_t * module , bool lock_acquired )
134
134
{
135
135
int ret , result_is_accel , target_is_accel , compare_is_accel ;
136
- void * compare_copy ;
137
- void * result_copy ;
136
+ const void * compare_copy ;
137
+ void * compare_to_free = NULL ;
138
+ void * result_copy = NULL ;
138
139
bool compare_copied = false;
139
140
bool result_copied = false;
140
141
@@ -168,13 +169,13 @@ static inline int ompi_osc_rdma_cas_local (const void *source_addr, const void *
168
169
}
169
170
170
171
if (compare_is_accel ) {
171
- compare_copy = malloc (datatype -> super .size );
172
+ compare_copy = compare_to_free = malloc (datatype -> super .size );
172
173
ret = opal_accelerator .mem_copy (MCA_ACCELERATOR_NO_DEVICE_ID , MCA_ACCELERATOR_NO_DEVICE_ID ,
173
- compare_copy , compare_addr , datatype -> super .size , MCA_ACCELERATOR_TRANSFER_DTOH );
174
+ compare_to_free , compare_addr , datatype -> super .size , MCA_ACCELERATOR_TRANSFER_DTOH );
174
175
compare_copied = true;
175
176
if (OPAL_SUCCESS != ret ) {
176
177
goto out ;
177
- }
178
+ }
178
179
} else {
179
180
compare_copy = compare_addr ;
180
181
}
@@ -192,7 +193,7 @@ static inline int ompi_osc_rdma_cas_local (const void *source_addr, const void *
192
193
193
194
out :
194
195
if (compare_copied ) {
195
- free (compare_copy );
196
+ free (compare_to_free );
196
197
}
197
198
if (result_copied ) {
198
199
free (result_copy );
@@ -828,6 +829,7 @@ static inline int cas_rdma (ompi_osc_rdma_sync_t *sync, const void *source_addr,
828
829
volatile bool complete = false;
829
830
void * result_copy ;
830
831
const void * compare_copy ;
832
+ void * compare_to_free = NULL ;
831
833
bool result_copied = false;
832
834
bool compare_copied = false;
833
835
int mem_compare ;
@@ -860,9 +862,9 @@ static inline int cas_rdma (ompi_osc_rdma_sync_t *sync, const void *source_addr,
860
862
}
861
863
ret = osc_rdma_is_accel (compare_addr );
862
864
if (0 < ret ) {
863
- compare_copy = malloc (len );
865
+ compare_copy = compare_to_free = malloc (len );
864
866
ret = opal_accelerator .mem_copy (MCA_ACCELERATOR_NO_DEVICE_ID , MCA_ACCELERATOR_NO_DEVICE_ID ,
865
- compare_copy , compare_addr , len , MCA_ACCELERATOR_TRANSFER_DTOH );
867
+ compare_to_free , compare_addr , len , MCA_ACCELERATOR_TRANSFER_DTOH );
866
868
compare_copied = true;
867
869
} else if (0 == ret ) {
868
870
compare_copy = compare_addr ;
@@ -875,7 +877,7 @@ static inline int cas_rdma (ompi_osc_rdma_sync_t *sync, const void *source_addr,
875
877
876
878
mem_compare = memcmp (result_copy , compare_copy , len );
877
879
if (compare_copied ) {
878
- free (compare_copy );
880
+ free (compare_to_free );
879
881
}
880
882
if (result_copied ) {
881
883
free (result_copy );
0 commit comments