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@xxxxxxxxx> --- 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(-) diff --git a/arch/x86/kernel/cpu/sgx/reclaim.c b/arch/x86/kernel/cpu/sgx/reclaim.c index 67bda5528625..c5c0ba92ab63 100644 --- a/arch/x86/kernel/cpu/sgx/reclaim.c +++ b/arch/x86/kernel/cpu/sgx/reclaim.c @@ -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); } -- 2.24.1