diff --git a/compute/pzlatms.c b/compute/pzlatms.c
index ab0cbe473a3e2f647d295fd47ce1cf18fdbc2200..1f1d96636c541d5a950ab01af40272af01215a33 100644
--- a/compute/pzlatms.c
+++ b/compute/pzlatms.c
@@ -155,6 +155,7 @@ void chameleon_pzlatms( cham_dist_t idist, unsigned long long int seed, cham_sym
                 if ( alloc_d ) {
                     free( D );
                 }
+                return;
             }
         }
     }
diff --git a/coreblas/compute/core_zlatm1.c b/coreblas/compute/core_zlatm1.c
index 18a823e59eed6302554bbfd8dfbead4ca1372ab5..1d79237c36c0b49035f8bc09966b89200c41ad1c 100644
--- a/coreblas/compute/core_zlatm1.c
+++ b/coreblas/compute/core_zlatm1.c
@@ -130,7 +130,7 @@ int CORE_zlatm1( int MODE, double COND, int IRSIGN, cham_dist_t DIST,
         coreblas_error(3, "illegal value of COND");
         return -3;
     }
-    if ( ( (MODE != -6) || (MODE != 6) ) &&
+    if ( ( (MODE == -6) || (MODE == 6) ) &&
          ( (DIST < ChamDistUniform) || (DIST > ChamDistSymmetric) ) )
     {
         coreblas_error(4, "illegal value of DIST");