@@ -133,8 +133,9 @@ static inline int ompi_osc_rdma_cas_local (const void *source_addr, const void *
133133 ompi_osc_rdma_module_t * module , bool lock_acquired )
134134{
135135 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 ;
138139 bool compare_copied = false;
139140 bool result_copied = false;
140141
@@ -168,13 +169,13 @@ static inline int ompi_osc_rdma_cas_local (const void *source_addr, const void *
168169 }
169170
170171 if (compare_is_accel ) {
171- compare_copy = malloc (datatype -> super .size );
172+ compare_copy = compare_to_free = malloc (datatype -> super .size );
172173 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 );
174175 compare_copied = true;
175176 if (OPAL_SUCCESS != ret ) {
176177 goto out ;
177- }
178+ }
178179 } else {
179180 compare_copy = compare_addr ;
180181 }
@@ -192,7 +193,7 @@ static inline int ompi_osc_rdma_cas_local (const void *source_addr, const void *
192193
193194out :
194195 if (compare_copied ) {
195- free (compare_copy );
196+ free (compare_to_free );
196197 }
197198 if (result_copied ) {
198199 free (result_copy );
@@ -828,6 +829,7 @@ static inline int cas_rdma (ompi_osc_rdma_sync_t *sync, const void *source_addr,
828829 volatile bool complete = false;
829830 void * result_copy ;
830831 const void * compare_copy ;
832+ void * compare_to_free = NULL ;
831833 bool result_copied = false;
832834 bool compare_copied = false;
833835 int mem_compare ;
@@ -860,9 +862,9 @@ static inline int cas_rdma (ompi_osc_rdma_sync_t *sync, const void *source_addr,
860862 }
861863 ret = osc_rdma_is_accel (compare_addr );
862864 if (0 < ret ) {
863- compare_copy = malloc (len );
865+ compare_copy = compare_to_free = malloc (len );
864866 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 );
866868 compare_copied = true;
867869 } else if (0 == ret ) {
868870 compare_copy = compare_addr ;
@@ -875,7 +877,7 @@ static inline int cas_rdma (ompi_osc_rdma_sync_t *sync, const void *source_addr,
875877
876878 mem_compare = memcmp (result_copy , compare_copy , len );
877879 if (compare_copied ) {
878- free (compare_copy );
880+ free (compare_to_free );
879881 }
880882 if (result_copied ) {
881883 free (result_copy );
0 commit comments