> 
> Note: while in such cases the underlying crypto assets are regenrated, it
                                                             ^
                                                             regenerated


[...]

> +/* Mutex to ensure no concurrent EPC accesses during EUPDATESVN */
> +static DEFINE_MUTEX(sgx_svn_lock);
> +
>  int sgx_inc_usage_count(void)
>  {
> +     int ret;
> +
> +     guard(mutex)(&sgx_svn_lock);
> +
> +     if (sgx_usage_count++ == 0) {
> +             ret = sgx_update_svn();
> +             if (ret)
> +                     sgx_usage_count--;
> +             return ret;
> +     }
> +

To me, I would prefer:

int sgx_inc_usage_count(void)
{
        guard(mutex)(&sgx_svn_lock);

        if (!sgx_usage_count) {
                int ret = sgx_update_svn();
                if (ret)
                        return ret;
        }

        sgx_usage_count++;

        return 0;
}

Reply via email to