From: Toshihiro Kobayashi Date: Thu, 30 Nov 2006 23:26:50 +0000 (-0800) Subject: ARM: OMAP: mailbox module stability fix X-Git-Tag: v2.6.19-omap1~25 X-Git-Url: http://pilppa.com/gitweb/?a=commitdiff_plain;h=d5010964aecf28bb9ddbb9546f7348dba714d536;p=linux-2.6-omap-h63xx.git ARM: OMAP: mailbox module stability fix mbox objects must be initialized before request_irq(). Signed-off-by: Toshihiro Kobayashi Signed-off-by: Tony Lindgren --- diff --git a/arch/arm/plat-omap/mailbox.c b/arch/arm/plat-omap/mailbox.c index 1d3761fae0f..723c92fa1e1 100644 --- a/arch/arm/plat-omap/mailbox.c +++ b/arch/arm/plat-omap/mailbox.c @@ -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);