[intel-sgx-kernel-dev,1/4] intel_sgx: Abort sgx_vma_do_fault if do_eldu fails
diff mbox

Message ID 1484081758-20302-2-git-send-email-sean.j.christopherson@intel.com
State New
Headers show

Commit Message

Sean Christopherson Jan. 10, 2017, 8:55 p.m. UTC
Signed-off-by: Sean Christopherson <sean.j.christopherson@intel.com>
Reviewed-by: Jarkko Sakkinen <jarkko.sakkine@linux.intel.com>
---
 drivers/platform/x86/intel_sgx_vma.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

Patch
diff mbox

diff --git a/drivers/platform/x86/intel_sgx_vma.c b/drivers/platform/x86/intel_sgx_vma.c
index c7b406b..e8a67b6 100644
--- a/drivers/platform/x86/intel_sgx_vma.c
+++ b/drivers/platform/x86/intel_sgx_vma.c
@@ -243,7 +243,13 @@  static struct sgx_encl_page *sgx_vma_do_fault(struct vm_area_struct *vma,
 		goto out;
 	}
 
-	do_eldu(encl, entry, epc_page, backing, false /* is_secs */);
+	rc = do_eldu(encl, entry, epc_page, backing, false /* is_secs */);
+	if (rc) {
+		sgx_put_backing(backing, 0);
+		entry = ERR_PTR(rc);
+		goto out;
+	}
+
 	rc = vm_insert_pfn(vma, entry->addr, PFN_DOWN(epc_page->pa));
 	sgx_put_backing(backing, 0);