ECDH: Fix error checks in benchmark.c
diff --git a/programs/test/benchmark.c b/programs/test/benchmark.c
old mode 100644
new mode 100755
index a808a84..0d4837f
--- a/programs/test/benchmark.c
+++ b/programs/test/benchmark.c
@@ -225,6 +225,14 @@
     return( 0 );
 }
 
+#if defined(MBEDTLS_ECDH_C)
+static void check( int r )
+{
+    if( r != 0 )
+        mbedtls_exit( 1 );
+}
+#endif
+
 /*
  * Clear some memory that was used to prepare the context
  */
@@ -1003,8 +1011,8 @@
         {
             mbedtls_ecdh_init( &ecdh_srv );
             mbedtls_ecdh_init( &ecdh_cli );
-            mbedtls_ecdh_setup( &ecdh_srv, curve_info->grp_id );
-            mbedtls_ecdh_setup( &ecdh_cli, curve_info->grp_id );
+            check( mbedtls_ecdh_setup( &ecdh_srv, curve_info->grp_id ) );
+            check( mbedtls_ecdh_setup( &ecdh_cli, curve_info->grp_id ) );
 
 #if defined(MBEDTLS_ECDH_LEGACY_CONTEXT)
             if (mbedtls_ecp_group_load(&ecdh_srv.grp, curve_info->grp_id) != 0 ||
@@ -1023,15 +1031,15 @@
             mbedtls_snprintf( title, sizeof( title ), "ECDHE-%s", curve_info->name );
             TIME_PUBLIC( title, "full handshake",
                 const unsigned char * p_srv = buf_srv;
-                ret |= mbedtls_ecdh_make_params( &ecdh_srv, &olen, buf_srv, sizeof( buf_srv ), myrand, NULL );
+                check( mbedtls_ecdh_make_params( &ecdh_srv, &olen, buf_srv, sizeof( buf_srv ), myrand, NULL ) );
 
-                ret |= mbedtls_ecdh_read_params( &ecdh_cli, &p_srv, p_srv + olen );
-                ret |= mbedtls_ecdh_make_public( &ecdh_cli, &olen, buf_cli, sizeof( buf_cli ), myrand, NULL );
+                check( mbedtls_ecdh_read_params( &ecdh_cli, &p_srv, p_srv + olen ) );
+                check( mbedtls_ecdh_make_public( &ecdh_cli, &olen, buf_cli, sizeof( buf_cli ), myrand, NULL ) );
 
-                ret |= mbedtls_ecdh_read_public( &ecdh_srv, buf_cli, olen );
-                ret |= mbedtls_ecdh_calc_secret( &ecdh_srv, &olen, buf_srv, sizeof( buf_srv ), myrand, NULL );
+                check( mbedtls_ecdh_read_public( &ecdh_srv, buf_cli, olen ) );
+                check( mbedtls_ecdh_calc_secret( &ecdh_srv, &olen, buf_srv, sizeof( buf_srv ), myrand, NULL ) );
 
-                ret |= mbedtls_ecdh_calc_secret( &ecdh_cli, &olen, buf_cli, sizeof( buf_cli ), myrand, NULL );
+                check( mbedtls_ecdh_calc_secret( &ecdh_cli, &olen, buf_cli, sizeof( buf_cli ), myrand, NULL ) );
             );
 
             mbedtls_ecdh_free( &ecdh_srv );