]> pilppa.org Git - linux-2.6-omap-h63xx.git/commitdiff
ARM: OMAP: mailbox module stability fix
authorToshihiro Kobayashi <toshihiro.kobayashi@nokia.com>
Thu, 30 Nov 2006 23:26:50 +0000 (15:26 -0800)
committerTony Lindgren <tony@atomide.com>
Thu, 30 Nov 2006 23:26:50 +0000 (15:26 -0800)
mbox objects must be initialized before request_irq().

Signed-off-by: Toshihiro Kobayashi <toshihiro.kobayashi@nokia.com>
Signed-off-by: Tony Lindgren <tony@atomide.com>
arch/arm/plat-omap/mailbox.c

index 1d3761fae0f92633bcec7499e94c34dd589c4d70..723c92fa1e1348fcf67086891618e16869709f9f 100644 (file)
@@ -238,30 +238,32 @@ static int omap_mbox_init(struct omap_mbox *mbox)
                goto fail1;
        }
 
+       spin_lock_init(&mbox->lock);
+       INIT_WORK(&mbox->msg_receive, mbox_msg_receiver, mbox);
+       init_waitqueue_head(&mbox->tx_waitq);
+
+       ret = mbq_init(&mbox->mbq);
+       if (unlikely(ret))
+               goto fail2;
+
        ret = request_irq(mbox->irq, mbox_interrupt, SA_INTERRUPT,
                          mbox->name, mbox);
        if (unlikely(ret)) {
                printk(KERN_ERR
                       "failed to register mailbox interrupt:%d\n", ret);
-               goto fail1;
+               goto fail3;
        }
        disable_mbox_irq(mbox, IRQ_RX);
        enable_mbox_irq(mbox, IRQ_RX);
 
-       spin_lock_init(&mbox->lock);
-       INIT_WORK(&mbox->msg_receive, mbox_msg_receiver, mbox);
-       init_waitqueue_head(&mbox->tx_waitq);
-
-       ret = mbq_init(&mbox->mbq);
-       if (unlikely(ret))
-               goto fail2;
-
        return 0;
+
+ fail3:
+       kfree(mbox->mbq);
  fail2:
-       free_irq(mbox->irq, mbox);
        class_remove_file(&omap_mbox_class, &class_attr_mbox);
-       class_unregister(&omap_mbox_class);
  fail1:
+       class_unregister(&omap_mbox_class);
        if (unlikely(mbox->ops->shutdown))
                mbox->ops->shutdown(mbox);
 
@@ -271,6 +273,7 @@ static int omap_mbox_init(struct omap_mbox *mbox)
 static void omap_mbox_shutdown(struct omap_mbox *mbox)
 {
        free_irq(mbox->irq, mbox);
+       kfree(mbox->mbq);
        class_remove_file(&omap_mbox_class, &class_attr_mbox);
        class_unregister(&omap_mbox_class);