Message ID | 20191010214301.25669-9-sean.j.christopherson@intel.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | x86/sgx: misc page related fixes | expand |
diff --git a/arch/x86/kernel/cpu/sgx/main.c b/arch/x86/kernel/cpu/sgx/main.c index e22cdbb431a3..48a4f37b5b3c 100644 --- a/arch/x86/kernel/cpu/sgx/main.c +++ b/arch/x86/kernel/cpu/sgx/main.c @@ -216,9 +216,10 @@ static bool __init sgx_alloc_epc_section(u64 addr, u64 size, page->desc = (addr + (i << PAGE_SHIFT)) | index; list_add_tail(&page->list, §ion->unsanitized_page_list); - sgx_nr_free_pages++; } + sgx_nr_free_pages += nr_pages; + return true; err_out:
Update the number of free pages only after an EPC section is fully initialized, else the free page count will be left in a bogus state if allocation fails. Signed-off-by: Sean Christopherson <sean.j.christopherson@intel.com> --- arch/x86/kernel/cpu/sgx/main.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)