Skip to contentSkip to conversation

physdev: Check for negative irqs in alloc_irq_vector

PATCH New Herbert Xu 1 participant 1 message Aug 30, 2006

lore
Share & tools
lore

Herbert Xu

author
#0 lore raw

PATCH 1/1 physdev: Check for negative irqs in alloc_irq_vector

Hi Keir:

[PATCH] physdev: Check for negative irqs in alloc_irq_vector

Since we're checking the validity of the supplied irq element in PHYSDEVOP_alloc_irq_vector, we might as well check it completely as a negtive irq is just as lethal as one above NR_IRQS.

Cheers,

Signature · 21 lines
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
--
diff -r 8273f730371b xen/arch/x86/physdev.c
--- a/xen/arch/x86/physdev.c	Tue Aug 29 12:23:11 2006 +0100
+++ b/xen/arch/x86/physdev.c	Wed Aug 30 21:15:19 2006 +1000
@@ -96,9 +96,10 @@ long do_physdev_op(int cmd, XEN_GUEST_HA
         if ( !IS_PRIV(current->domain) )
             break;
 
+	irq = irq_op.irq;
         ret = -EINVAL;
-        if ( (irq = irq_op.irq) >= NR_IRQS )
-            break;
+	if ( (irq < 0) || (irq >= NR_IRQS) )
+	    break;
         
         irq_op.vector = assign_irq_vector(irq);
         ret = copy_to_guest(arg, &irq_op, 1) ? -EFAULT : 0;