From: Jan Beulich Date: Wed, 9 Feb 2022 11:50:28 +0000 (+0100) Subject: x86/mm: tidy XENMEM_{get,set}_pod_target handling X-Git-Tag: archive/raspbian/4.17.0-1+rpi1^2~33^2~1049 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=551b0e6de57aca5006e3eff20cfacc4a4caf6a5d;p=xen.git x86/mm: tidy XENMEM_{get,set}_pod_target handling Do away with the "pod_target_out_unlock" label. In particular by folding if()-s, the logic can be expressed with less code (and no goto-s) this way. Signed-off-by: Jan Beulich Acked-by: Roger Pau Monné --- diff --git a/xen/arch/x86/mm.c b/xen/arch/x86/mm.c index 98edf5b89c..b80e4ab9c5 100644 --- a/xen/arch/x86/mm.c +++ b/xen/arch/x86/mm.c @@ -4810,24 +4810,18 @@ long arch_memory_op(unsigned long cmd, XEN_GUEST_HANDLE_PARAM(void) arg) if ( d == NULL ) return -ESRCH; - if ( cmd == XENMEM_set_pod_target ) - rc = xsm_set_pod_target(XSM_PRIV, d); - else - rc = xsm_get_pod_target(XSM_PRIV, d); - - if ( rc != 0 ) - goto pod_target_out_unlock; - if ( cmd == XENMEM_set_pod_target ) { - if ( target.target_pages > d->max_pages ) - { + rc = xsm_set_pod_target(XSM_PRIV, d); + if ( rc ) + ASSERT(rc < 0); + else if ( target.target_pages > d->max_pages ) rc = -EINVAL; - goto pod_target_out_unlock; - } - - rc = p2m_pod_set_mem_target(d, target.target_pages); + else + rc = p2m_pod_set_mem_target(d, target.target_pages); } + else + rc = xsm_get_pod_target(XSM_PRIV, d); if ( rc == -ERESTART ) { @@ -4842,13 +4836,9 @@ long arch_memory_op(unsigned long cmd, XEN_GUEST_HANDLE_PARAM(void) arg) target.pod_entries = p2m->pod.entry_count; if ( __copy_to_guest(arg, &target, 1) ) - { - rc= -EFAULT; - goto pod_target_out_unlock; - } + rc = -EFAULT; } - pod_target_out_unlock: rcu_unlock_domain(d); return rc; }