diff options
Diffstat (limited to 'virt/lib/irqbypass.c')
-rw-r--r-- | virt/lib/irqbypass.c | 38 |
1 files changed, 20 insertions, 18 deletions
diff --git a/virt/lib/irqbypass.c b/virt/lib/irqbypass.c index 43de8ae78fa1..28fda42e471b 100644 --- a/virt/lib/irqbypass.c +++ b/virt/lib/irqbypass.c @@ -85,6 +85,7 @@ int irq_bypass_register_producer(struct irq_bypass_producer *producer) { struct irq_bypass_producer *tmp; struct irq_bypass_consumer *consumer; + int ret; if (!producer->token) return -EINVAL; @@ -98,20 +99,16 @@ int irq_bypass_register_producer(struct irq_bypass_producer *producer) list_for_each_entry(tmp, &producers, node) { if (tmp->token == producer->token) { - mutex_unlock(&lock); - module_put(THIS_MODULE); - return -EBUSY; + ret = -EBUSY; + goto out_err; } } list_for_each_entry(consumer, &consumers, node) { if (consumer->token == producer->token) { - int ret = __connect(producer, consumer); - if (ret) { - mutex_unlock(&lock); - module_put(THIS_MODULE); - return ret; - } + ret = __connect(producer, consumer); + if (ret) + goto out_err; break; } } @@ -121,6 +118,10 @@ int irq_bypass_register_producer(struct irq_bypass_producer *producer) mutex_unlock(&lock); return 0; +out_err: + mutex_unlock(&lock); + module_put(THIS_MODULE); + return ret; } EXPORT_SYMBOL_GPL(irq_bypass_register_producer); @@ -179,6 +180,7 @@ int irq_bypass_register_consumer(struct irq_bypass_consumer *consumer) { struct irq_bypass_consumer *tmp; struct irq_bypass_producer *producer; + int ret; if (!consumer->token || !consumer->add_producer || !consumer->del_producer) @@ -193,20 +195,16 @@ int irq_bypass_register_consumer(struct irq_bypass_consumer *consumer) list_for_each_entry(tmp, &consumers, node) { if (tmp->token == consumer->token || tmp == consumer) { - mutex_unlock(&lock); - module_put(THIS_MODULE); - return -EBUSY; + ret = -EBUSY; + goto out_err; } } list_for_each_entry(producer, &producers, node) { if (producer->token == consumer->token) { - int ret = __connect(producer, consumer); - if (ret) { - mutex_unlock(&lock); - module_put(THIS_MODULE); - return ret; - } + ret = __connect(producer, consumer); + if (ret) + goto out_err; break; } } @@ -216,6 +214,10 @@ int irq_bypass_register_consumer(struct irq_bypass_consumer *consumer) mutex_unlock(&lock); return 0; +out_err: + mutex_unlock(&lock); + module_put(THIS_MODULE); + return ret; } EXPORT_SYMBOL_GPL(irq_bypass_register_consumer); |