[Lguest] [RESEND PATCH] lguest: Make sure the interrupt is allocated correctly by lguest_setup_irq.
Stratos Psomadakis
psomas at cslab.ece.ntua.gr
Sun May 22 19:02:36 EST 2011
Make sure the interrupt is allocated correctly by lguest_setup_irq (check the
return value of irq_alloc_desc_at for -ENOMEM)
Signed-off-by: Stratos Psomadakis <psomas at cslab.ece.ntua.gr>
---
arch/x86/lguest/boot.c | 15 ++++++++++-----
drivers/lguest/lguest_device.c | 6 ++++--
2 files changed, 14 insertions(+), 7 deletions(-)
diff --git a/arch/x86/lguest/boot.c b/arch/x86/lguest/boot.c
index 1cd6089..7de7bee 100644
--- a/arch/x86/lguest/boot.c
+++ b/arch/x86/lguest/boot.c
@@ -840,15 +840,20 @@ static void __init lguest_init_IRQ(void)
* With CONFIG_SPARSE_IRQ, interrupt descriptors are allocated as-needed, so
* rather than set them in lguest_init_IRQ we are called here every time an
* lguest device needs an interrupt.
- *
- * FIXME: irq_alloc_desc_at() can fail due to lack of memory, we should
- * pass that up!
*/
-void lguest_setup_irq(unsigned int irq)
+int lguest_setup_irq(unsigned int irq)
{
- irq_alloc_desc_at(irq, 0);
+ int err;
+
+ err = irq_alloc_desc_at(irq, 0);
+ if (err)
+ goto out;
+
irq_set_chip_and_handler_name(irq, &lguest_irq_controller,
handle_level_irq, "level");
+
+out:
+ return err;
}
/*
diff --git a/drivers/lguest/lguest_device.c b/drivers/lguest/lguest_device.c
index 69c84a1..b2edd86 100644
--- a/drivers/lguest/lguest_device.c
+++ b/drivers/lguest/lguest_device.c
@@ -233,7 +233,7 @@ static void lg_notify(struct virtqueue *vq)
}
/* An extern declaration inside a C file is bad form. Don't do it. */
-extern void lguest_setup_irq(unsigned int irq);
+extern int lguest_setup_irq(unsigned int irq);
/*
* This routine finds the Nth virtqueue described in the configuration of
@@ -294,7 +294,9 @@ static struct virtqueue *lg_find_vq(struct virtio_device *vdev,
}
/* Make sure the interrupt is allocated. */
- lguest_setup_irq(lvq->config.irq);
+ err = lguest_setup_irq(lvq->config.irq);
+ if (err == -ENOMEM)
+ goto vring_del_virtqueue(vq);
/*
* Tell the interrupt for this virtqueue to go to the virtio_ring
--
1.7.5.rc3
More information about the Lguest
mailing list