Skip to content

Commit a979a6a

Browse files
Zhu Lingshanmstsirkin
authored andcommitted
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 <[email protected]> Suggested-by: Jason Wang <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Michael S. Tsirkin <[email protected]>
1 parent 3597a2f commit a979a6a

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

virt/lib/irqbypass.c

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,17 +40,21 @@ static int __connect(struct irq_bypass_producer *prod,
4040
if (prod->add_consumer)
4141
ret = prod->add_consumer(prod, cons);
4242

43-
if (!ret) {
44-
ret = cons->add_producer(cons, prod);
45-
if (ret && prod->del_consumer)
46-
prod->del_consumer(prod, cons);
47-
}
43+
if (ret)
44+
goto err_add_consumer;
45+
46+
ret = cons->add_producer(cons, prod);
47+
if (ret)
48+
goto err_add_producer;
4849

4950
if (cons->start)
5051
cons->start(cons);
5152
if (prod->start)
5253
prod->start(prod);
53-
54+
err_add_producer:
55+
if (prod->del_consumer)
56+
prod->del_consumer(prod, cons);
57+
err_add_consumer:
5458
return ret;
5559
}
5660

0 commit comments

Comments
 (0)