Module: xenomai-head
Branch: master
Commit: 737e3bb09e2364658cfc59a0037f5e39a81fb799
URL:    
http://git.xenomai.org/?p=xenomai-head.git;a=commit;h=737e3bb09e2364658cfc59a0037f5e39a81fb799

Author: Philippe Gerum <r...@xenomai.org>
Date:   Sun Oct 24 22:22:54 2010 +0200

nucleus/intr: sanitize IRQ number validation

---

 ksrc/nucleus/intr.c |   16 +++++-----------
 1 files changed, 5 insertions(+), 11 deletions(-)

diff --git a/ksrc/nucleus/intr.c b/ksrc/nucleus/intr.c
index a6de4ea..0d6f64b 100644
--- a/ksrc/nucleus/intr.c
+++ b/ksrc/nucleus/intr.c
@@ -599,7 +599,8 @@ int __init xnintr_mount(void)
  * - XN_ISR_EDGE is an additional flag need to be set together with 
XN_ISR_SHARED
  * to enable IRQ-sharing of edge-triggered interrupts.
  *
- * @return No error condition being defined, 0 is always returned.
+ * @return 0 is returned on success. Otherwise, -EINVAL is returned if
+ * @a irq is not a valid interrupt number.
  *
  * Environments:
  *
@@ -615,6 +616,9 @@ int xnintr_init(xnintr_t *intr,
                const char *name,
                unsigned irq, xnisr_t isr, xniack_t iack, xnflags_t flags)
 {
+       if (irq >= XNARCH_NR_IRQS)
+               return -EINVAL;
+
        intr->irq = irq;
        intr->isr = isr;
        intr->iack = iack;
@@ -719,11 +723,6 @@ int xnintr_attach(xnintr_t *intr, void *cookie)
 
        xnlock_get_irqsave(&intrlock, s);
 
-       if (intr->irq >= XNARCH_NR_IRQS) {
-               ret = -EINVAL;
-               goto out;
-       }
-
        if (__testbits(intr->flags, XN_ISR_ATTACHED)) {
                ret = -EBUSY;
                goto out;
@@ -782,11 +781,6 @@ int xnintr_detach(xnintr_t *intr)
 
        xnlock_get_irqsave(&intrlock, s);
 
-       if (intr->irq >= XNARCH_NR_IRQS) {
-               ret = -EINVAL;
-               goto out;
-       }
-
        if (!__testbits(intr->flags, XN_ISR_ATTACHED)) {
                ret = -EINVAL;
                goto out;


_______________________________________________
Xenomai-git mailing list
Xenomai-git@gna.org
https://mail.gna.org/listinfo/xenomai-git

Reply via email to