diff options
author | Zhu Lingshan <lingshan.zhu@intel.com> | 2020-07-31 14:55:33 +0800 |
---|---|---|
committer | Michael S. Tsirkin <mst@redhat.com> | 2020-08-05 11:08:42 -0400 |
commit | a979a6aa009f3c99689432e0cdb5402a4463fb88 (patch) | |
tree | be8ef4c7fa1ff87da6c9b9bba6987c2dfc714fef /virt/lib | |
parent | 3597a2fba672cfd4112bbdbe6220127f280c8dba (diff) |
irqbypass: do not start cons/prod when failed connect
If failed to connect, there is no need to start consumer nor
producer.
Signed-off-by: Zhu Lingshan <lingshan.zhu@intel.com>
Suggested-by: Jason Wang <jasowang@redhat.com>
Link: https://lore.kernel.org/r/20200731065533.4144-7-lingshan.zhu@intel.com
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Diffstat (limited to 'virt/lib')
-rw-r--r-- | virt/lib/irqbypass.c | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/virt/lib/irqbypass.c b/virt/lib/irqbypass.c index 28fda42e471b..c9bb3957f58a 100644 --- a/virt/lib/irqbypass.c +++ b/virt/lib/irqbypass.c @@ -40,17 +40,21 @@ static int __connect(struct irq_bypass_producer *prod, if (prod->add_consumer) ret = prod->add_consumer(prod, cons); - if (!ret) { - ret = cons->add_producer(cons, prod); - if (ret && prod->del_consumer) - prod->del_consumer(prod, cons); - } + if (ret) + goto err_add_consumer; + + ret = cons->add_producer(cons, prod); + if (ret) + goto err_add_producer; if (cons->start) cons->start(cons); if (prod->start) prod->start(prod); - +err_add_producer: + if (prod->del_consumer) + prod->del_consumer(prod, cons); +err_add_consumer: return ret; } |