]> xenbits.xensource.com Git - xen.git/commitdiff
arm/irq: Reorder check when the IRQ is already used by someone
authorOleksandr Tyshchenko <olekstysh@gmail.com>
Fri, 2 Dec 2016 16:38:16 +0000 (18:38 +0200)
committerStefano Stabellini <sstabellini@kernel.org>
Thu, 16 Mar 2017 20:43:57 +0000 (13:43 -0700)
Call irq_get_domain for the IRQ we are interested in
only after making sure that it is the guest IRQ to avoid
ASSERT(test_bit(_IRQ_GUEST, &desc->status)) triggering.

Signed-off-by: Oleksandr Tyshchenko <oleksandr_tyshchenko@epam.com>
Signed-off-by: Andrii Anisov <andrii_anisov@epam.com>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
xen/arch/arm/irq.c

index 06d4843b45a79e661238d445347f5924f4613933..508028b02ea817518ffb7c8e4542d55e7c475be3 100644 (file)
@@ -477,26 +477,32 @@ int route_irq_to_guest(struct domain *d, unsigned int virq,
      */
     if ( desc->action != NULL )
     {
-        struct domain *ad = irq_get_domain(desc);
-
-        if ( test_bit(_IRQ_GUEST, &desc->status) && d == ad )
+        if ( test_bit(_IRQ_GUEST, &desc->status) )
         {
-            if ( irq_get_guest_info(desc)->virq != virq )
+            struct domain *ad = irq_get_domain(desc);
+
+            if ( d == ad )
+            {
+                if ( irq_get_guest_info(desc)->virq != virq )
+                {
+                    printk(XENLOG_G_ERR
+                           "d%u: IRQ %u is already assigned to vIRQ %u\n",
+                           d->domain_id, irq, irq_get_guest_info(desc)->virq);
+                    retval = -EBUSY;
+                }
+            }
+            else
             {
-                printk(XENLOG_G_ERR
-                       "d%u: IRQ %u is already assigned to vIRQ %u\n",
-                       d->domain_id, irq, irq_get_guest_info(desc)->virq);
+                printk(XENLOG_G_ERR "IRQ %u is already used by domain %u\n",
+                       irq, ad->domain_id);
                 retval = -EBUSY;
             }
-            goto out;
         }
-
-        if ( test_bit(_IRQ_GUEST, &desc->status) )
-            printk(XENLOG_G_ERR "IRQ %u is already used by domain %u\n",
-                   irq, ad->domain_id);
         else
+        {
             printk(XENLOG_G_ERR "IRQ %u is already used by Xen\n", irq);
-        retval = -EBUSY;
+            retval = -EBUSY;
+        }
         goto out;
     }