diff options
author | Keir Fraser <keir@xen.org> | 2011-01-26 08:56:44 +0000 |
---|---|---|
committer | Keir Fraser <keir@xen.org> | 2011-01-26 08:56:44 +0000 |
commit | f96101286a629a2cb4d4ebd24a1e57bdfc74a184 (patch) | |
tree | 166589b6f1435612f6f1d7f3e6e2fae483e451d0 | |
parent | 56bcfc196f19d9667c5ae8f6dc40d7e32a59a00e (diff) | |
download | xen-f96101286a629a2cb4d4ebd24a1e57bdfc74a184.tar.gz xen-f96101286a629a2cb4d4ebd24a1e57bdfc74a184.tar.bz2 xen-f96101286a629a2cb4d4ebd24a1e57bdfc74a184.zip |
x86: physdev_[un]map_pirq() use rcu_lock_target_domain_by_id().
More idiomatic, and avoids accidental failure to check caller
privilege. For example, the unmap path was not checking for any
privilege before calling unmap_domain_pirq_emuirq(), which can't be
right.
Signed-off-by: Keir Fraser <keir@xen.org>
-rw-r--r-- | xen/arch/x86/physdev.c | 19 |
1 files changed, 6 insertions, 13 deletions
diff --git a/xen/arch/x86/physdev.c b/xen/arch/x86/physdev.c index 5e0bbe174b..3454c03e03 100644 --- a/xen/arch/x86/physdev.c +++ b/xen/arch/x86/physdev.c @@ -87,14 +87,9 @@ static int physdev_map_pirq(struct physdev_map_pirq *map) struct msi_info _msi; void *map_data = NULL; - if ( !map ) - return -EINVAL; - - d = (map->domid == DOMID_SELF) ? rcu_lock_current_domain() - : rcu_lock_domain_by_id(map->domid); - - if ( d == NULL ) - return -ESRCH; + ret = rcu_lock_target_domain_by_id(map->domid, &d); + if ( ret ) + return ret; if ( map->domid == DOMID_SELF && is_hvm_domain(d) ) { @@ -225,11 +220,9 @@ static int physdev_unmap_pirq(struct physdev_unmap_pirq *unmap) struct domain *d; int ret; - d = (unmap->domid == DOMID_SELF) ? rcu_lock_current_domain() - : rcu_lock_domain_by_id(unmap->domid); - - if ( d == NULL ) - return -ESRCH; + ret = rcu_lock_target_domain_by_id(unmap->domid, &d); + if ( ret ) + return ret; if ( is_hvm_domain(d) ) { |