diff --git a/features/device_key/source/DeviceKey.cpp b/features/device_key/source/DeviceKey.cpp index d2125c6805..016b28c135 100644 --- a/features/device_key/source/DeviceKey.cpp +++ b/features/device_key/source/DeviceKey.cpp @@ -267,11 +267,12 @@ int DeviceKey::generate_key_by_random(uint32_t *output, size_t size) ret = mbedtls_entropy_func(entropy, (unsigned char *)output, size); if (ret != MBED_SUCCESS) { ret = DEVICEKEY_GENERATE_RANDOM_ERROR; + } else { + ret = DEVICEKEY_SUCCESS; } mbedtls_entropy_free(entropy); delete entropy; - ret = DEVICEKEY_SUCCESS; #endif return ret;