--- xen/common/domctl.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) Index: build-32-release304-13138/xen/common/domctl.c =================================================================== --- build-32-release304-13138.orig/xen/common/domctl.c +++ build-32-release304-13138/xen/common/domctl.c @@ -708,12 +708,21 @@ ret_t do_domctl(XEN_GUEST_HANDLE(xen_dom #ifdef CONFIG_COMPAT case XEN_DOMCTL_set_compat: - ret = switch_compat(find_domain_by_id(op->domain)); - break; - case XEN_DOMCTL_set_native: - ret = switch_native(find_domain_by_id(op->domain)); + { + struct domain *d; + + ret = -ESRCH; + d = find_domain_by_id(op->domain); + if (d) { + if (op->cmd == XEN_DOMCTL_set_compat) + ret = switch_compat(d); + else + ret = switch_native(d); + put_domain(d); + } break; + } #endif default: