domctl: Fix the wrong return values when xsm_xxx() returns 0
authorKeir Fraser <keir.fraser@citrix.com>
Mon, 29 Sep 2008 08:43:05 +0000 (09:43 +0100)
committerKeir Fraser <keir.fraser@citrix.com>
Mon, 29 Sep 2008 08:43:05 +0000 (09:43 +0100)
In 18423: 44f039c4aee4,  if xsm_xxx() returns 0, there are some places
where the return value would be incorrect. The patch fixes them.

Signed-off-by: Dexuan Cui <dexuan.cui@intel.com>
xen/arch/x86/domctl.c

index e2672e4794d6173aab47b37effe3ccb237c0ae8a..abbaa7f8a3e6911c1c5bd686c7949a552a4c156e 100644 (file)
@@ -620,14 +620,14 @@ long arch_do_domctl(
         if ( !iommu_enabled )
             break;
 
-        ret = -EINVAL;
-        bus = (domctl->u.assign_device.machine_bdf >> 16) & 0xff;
-        devfn = (domctl->u.assign_device.machine_bdf >> 8) & 0xff;
-
         ret = xsm_test_assign_device(domctl->u.assign_device.machine_bdf);
         if ( ret )
             break;
 
+        ret = -EINVAL;
+        bus = (domctl->u.assign_device.machine_bdf >> 16) & 0xff;
+        devfn = (domctl->u.assign_device.machine_bdf >> 8) & 0xff;
+
         if ( device_assigned(bus, devfn) )
         {
             gdprintk(XENLOG_ERR, "XEN_DOMCTL_test_assign_device: "
@@ -670,6 +670,7 @@ long arch_do_domctl(
             break;
         }
 
+        ret = -EINVAL;
         if ( device_assigned(bus, devfn) )
         {
             gdprintk(XENLOG_ERR, "XEN_DOMCTL_assign_device: "
@@ -751,6 +752,7 @@ long arch_do_domctl(
         if ( ret )
             goto bind_out;
 
+        ret = -ESRCH;
         if ( iommu_enabled )
             ret = pt_irq_create_bind_vtd(d, bind);
         if ( ret < 0 )