Don't add an EPC page to the free page list of EREMOVE fails, as doing so will cause any future attempt to use the EPC page to fail, and likely WARN as well. Signed-off-by: Sean Christopherson <sean.j.christopherson@xxxxxxxxx> --- arch/x86/kernel/cpu/sgx/main.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/arch/x86/kernel/cpu/sgx/main.c b/arch/x86/kernel/cpu/sgx/main.c index d45bf6fca0c8..8e7557d3ff03 100644 --- a/arch/x86/kernel/cpu/sgx/main.c +++ b/arch/x86/kernel/cpu/sgx/main.c @@ -138,7 +138,8 @@ int sgx_free_page(struct sgx_epc_page *page) spin_unlock(&sgx_active_page_list_lock); ret = __eremove(sgx_epc_addr(page)); - WARN_ONCE(ret, "EREMOVE returned %d (0x%x)", ret, ret); + if (WARN_ONCE(ret, "EREMOVE returned %d (0x%x)", ret, ret)) + return -EIO; spin_lock(§ion->lock); list_add_tail(&page->list, §ion->page_list); -- 2.22.0