Call sgx_free_va_slot() when the EWB flow fails. Otherwise, they will leak in the failure case. Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@xxxxxxxxxxxxxxx> --- arch/x86/kernel/cpu/sgx/reclaim.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/arch/x86/kernel/cpu/sgx/reclaim.c b/arch/x86/kernel/cpu/sgx/reclaim.c index f96f4c70f4a6..fb41141a28a7 100644 --- a/arch/x86/kernel/cpu/sgx/reclaim.c +++ b/arch/x86/kernel/cpu/sgx/reclaim.c @@ -341,12 +341,15 @@ static void sgx_encl_ewb(struct sgx_epc_page *epc_page, } } - if (ret) + if (ret) { if (encls_failed(ret) || encls_returned_code(ret)) ENCLS_WARN(ret, "EWB"); - encl_page->desc |= va_offset; - encl_page->va_page = va_page; + sgx_free_va_slot(va_page, va_offset); + } else { + encl_page->desc |= va_offset; + encl_page->va_page = va_page; + } } static void sgx_reclaimer_write(struct sgx_epc_page *epc_page) -- 2.20.1