Always check return status of mutex_(un)lock()
diff --git a/library/rsa.c b/library/rsa.c
index 1d6fd4a..6aee109 100644
--- a/library/rsa.c
+++ b/library/rsa.c
@@ -283,7 +283,8 @@
}
#if defined(MBEDTLS_THREADING_C)
- mbedtls_mutex_lock( &ctx->mutex );
+ if( ( ret = mbedtls_mutex_lock( &ctx->mutex ) ) != 0 )
+ return( ret );
#endif
olen = ctx->len;
@@ -292,7 +293,8 @@
cleanup:
#if defined(MBEDTLS_THREADING_C)
- mbedtls_mutex_unlock( &ctx->mutex );
+ if( ( ret = mbedtls_mutex_unlock( &ctx->mutex ) ) != 0 )
+ return( ret );
#endif
mbedtls_mpi_free( &T );
@@ -315,7 +317,8 @@
int ret, count = 0;
#if defined(MBEDTLS_THREADING_C)
- mbedtls_mutex_lock( &ctx->mutex );
+ if( ( ret = mbedtls_mutex_lock( &ctx->mutex ) ) != 0 )
+ return( ret );
#endif
if( ctx->Vf.p != NULL )
@@ -351,7 +354,8 @@
cleanup:
#if defined(MBEDTLS_THREADING_C)
- mbedtls_mutex_unlock( &ctx->mutex );
+ if( ( ret = mbedtls_mutex_unlock( &ctx->mutex ) ) != 0 )
+ return( ret );
#endif
return( ret );
@@ -408,7 +412,8 @@
}
#if defined(MBEDTLS_THREADING_C)
- mbedtls_mutex_lock( &ctx->mutex );
+ if( ( ret = mbedtls_mutex_lock( &ctx->mutex ) ) != 0 )
+ return( ret );
#endif
#if defined(MBEDTLS_RSA_NO_CRT)
@@ -452,7 +457,8 @@
cleanup:
#if defined(MBEDTLS_THREADING_C)
- mbedtls_mutex_unlock( &ctx->mutex );
+ if( ( ret = mbedtls_mutex_unlock( &ctx->mutex ) ) != 0 )
+ return( ret );
mbedtls_mpi_free( &Vi_copy ); mbedtls_mpi_free( &Vf_copy );
#endif
mbedtls_mpi_free( &T ); mbedtls_mpi_free( &T1 ); mbedtls_mpi_free( &T2 );