From: Herbert Xu Subject: [PATCH] physdev: Check for negative irqs in alloc_irq_vector Date: Wed, 30 Aug 2006 21:18:57 +1000 Message-ID: <20060830111857.GA21616@gondor.apana.org.au> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Content-Disposition: inline List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: Keir Fraser , Xen Development Mailing List List-Id: xen-devel@lists.xenproject.org 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. Signed-off-by: Herbert Xu Cheers, -- Visit Openswan at http://www.openswan.org/ Email: Herbert Xu ~{PmV>HI~} 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;