goldfish: Sanitize the broken interrupt handler
authorThomas Gleixner <tglx@linutronix.de>
Wed, 15 Feb 2017 10:11:51 +0000 (11:11 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 15 Feb 2017 16:49:58 +0000 (08:49 -0800)
This interrupt handler is broken in several ways:

  - It loops forever when the op code is not decodeable

  - It never returns IRQ_HANDLED because the only way to exit the loop
    returns IRQ_NONE unconditionally.

The whole concept of this is broken. Creating devices in an interrupt
handler is beyond any point of sanity.

Make it at least behave halfways sane so accidental users do not have to
deal with a hard to debug lockup.

Fixes: e809c22b8fb028 ("goldfish: add the goldfish virtual bus")
Reported-by: Gabriel C <nix.or.die@gmail.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Acked-by: Linus Torvalds <torvalds@linux-foundation.org>
Cc: stable@vger.kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/platform/goldfish/pdev_bus.c

index 1f52462f4cdd4b7e1431723ca37b32c267da68a1..dd9ea463c2a4a547c2d26e32ed61c5990832a9e5 100644 (file)
@@ -157,23 +157,26 @@ static int goldfish_new_pdev(void)
 static irqreturn_t goldfish_pdev_bus_interrupt(int irq, void *dev_id)
 {
        irqreturn_t ret = IRQ_NONE;
+
        while (1) {
                u32 op = readl(pdev_bus_base + PDEV_BUS_OP);
-               switch (op) {
-               case PDEV_BUS_OP_DONE:
-                       return IRQ_NONE;
 
+               switch (op) {
                case PDEV_BUS_OP_REMOVE_DEV:
                        goldfish_pdev_remove();
+                       ret = IRQ_HANDLED;
                        break;
 
                case PDEV_BUS_OP_ADD_DEV:
                        goldfish_new_pdev();
+                       ret = IRQ_HANDLED;
                        break;
+
+               case PDEV_BUS_OP_DONE:
+               default:
+                       return ret;
                }
-               ret = IRQ_HANDLED;
        }
-       return ret;
 }
 
 static int goldfish_pdev_bus_probe(struct platform_device *pdev)