diff mbox series

[for_v25,1/4] x86/sgx: Put SECS backing iff retrieving the backing succeeds

Message ID 20191221003156.27236-2-sean.j.christopherson@intel.com (mailing list archive)
State New, archived
Headers show
Series x86/sgx: Reclaim bug fix and cleanup | expand

Commit Message

Sean Christopherson Dec. 21, 2019, 12:31 a.m. UTC
Put the SECS backing if and only if retrieving the backing succeeded,
otherwise sgx_encl_put_backing() will consume uninitialized pointers.

Signed-off-by: Sean Christopherson <sean.j.christopherson@intel.com>
---
 arch/x86/kernel/cpu/sgx/reclaim.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/arch/x86/kernel/cpu/sgx/reclaim.c b/arch/x86/kernel/cpu/sgx/reclaim.c
index 21fbfe2ed9c4..67bda5528625 100644
--- a/arch/x86/kernel/cpu/sgx/reclaim.c
+++ b/arch/x86/kernel/cpu/sgx/reclaim.c
@@ -361,9 +361,9 @@  static void sgx_reclaimer_write(struct sgx_epc_page *epc_page,
 
 				sgx_free_page(encl->secs.epc_page);
 				encl->secs.epc_page = NULL;
+
+				sgx_encl_put_backing(&secs_backing, true);
 			}
-
-			sgx_encl_put_backing(&secs_backing, true);
 		}
 	}