@@ -355,18 +355,19 @@ static void sgx_reclaimer_write(struct sgx_epc_page *epc_page,
} else if (atomic_read(&encl->flags) & SGX_ENCL_INITIALIZED) {
ret = sgx_encl_get_backing(encl, PFN_DOWN(encl->size),
&secs_backing);
- if (!ret) {
- sgx_encl_ewb(encl->secs.epc_page,
- &secs_backing);
+ if (ret)
+ goto out;
- sgx_free_page(encl->secs.epc_page);
- encl->secs.epc_page = NULL;
+ sgx_encl_ewb(encl->secs.epc_page, &secs_backing);
- sgx_encl_put_backing(&secs_backing, true);
- }
+ sgx_free_page(encl->secs.epc_page);
+ encl->secs.epc_page = NULL;
+
+ sgx_encl_put_backing(&secs_backing, true);
}
}
+out:
mutex_unlock(&encl->lock);
}
Use a goto for the SECS backing error path in sgx_reclaimer_write() so that the happy path is a straight shot, e.g. to make it obvious that the backing is not being leaked. Reducing the indentation also eliminates a line wrap. No functional change intended. Signed-off-by: Sean Christopherson <sean.j.christopherson@intel.com> --- I could go either way on this patch, included it in case you have a preference. arch/x86/kernel/cpu/sgx/reclaim.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-)