From: Ameya Palande Subject: [PATCHv2] OMAP3: Keypad: Fix failure exit path in probe Date: Tue, 7 Sep 2010 16:24:03 +0300 Message-ID: <1283865843-10178-1-git-send-email-ameya.palande@nokia.com> References: <1283860305-22585-1-git-send-email-manjugk@ti.com> Return-path: Received: from mgw-sa02.nokia.com ([147.243.1.48]:58932 "EHLO mgw-sa02.nokia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751657Ab0IGNYH (ORCPT ); Tue, 7 Sep 2010 09:24:07 -0400 In-Reply-To: <1283860305-22585-1-git-send-email-manjugk@ti.com> Sender: linux-omap-owner@vger.kernel.org List-Id: linux-omap@vger.kernel.org To: linux-omap@vger.kernel.org Cc: tony@atomide.com, manjugk@ti.com From: ext G, Manjunath Kondaiah The failure exit paths seems to be wrong in probe function. This patch corrects exit failure paths for error handling cases. Boot warning incase of request irq failure: [ 1.553985] twl4030_keypad twl4030_keypad: request_irq failed for irq no=369 [ 1.561157] ------------[ cut here ]------------ [ 1.565795] WARNING: at kernel/irq/manage.c:899 __free_irq+0x88/0x164() [ 1.572418] Trying to free already-free IRQ 369 [ 1.576965] Modules linked in: [ 1.580047] [] (unwind_backtrace+0x0/0xe4) from [] (warn_slowpath_common+0x4c/0x64) [ 1.589477] [] (warn_slowpath_common+0x4c/0x64) from [] (warn_slowpath_fmt+0x2c/0x3c) [ 1.599060] [] (warn_slowpath_fmt+0x2c/0x3c) from [] (__free_irq+0x88/0x164) [ 1.607849] [] (__free_irq+0x88/0x164) from [] (free_irq+0x3c/0x5c) [ 1.615875] [] (free_irq+0x3c/0x5c) from [] (twl4030_kp_probe+0x308/0x374) [ 1.624511] [] (twl4030_kp_probe+0x308/0x374) from [] (platform_drv_probe+0x14/0x18) [ 1.634033] [] (platform_drv_probe+0x14/0x18) from [] (driver_probe_device+0xc8/0x184) [ 1.643707] [] (driver_probe_device+0xc8/0x184) from [] (__driver_attach+0x68/0x8c) [ 1.653106] [] (__driver_attach+0x68/0x8c) from [] (bus_for_each_dev+0x48/0x74) [ 1.662170] [] (bus_for_each_dev+0x48/0x74) from [] (bus_add_driver+0x9c/0x210) [ 1.671234] [] (bus_add_driver+0x9c/0x210) from [] (driver_register+0xa8/0x134) [ 1.680297] [] (driver_register+0xa8/0x134) from [] (do_one_initcall+0x58/0x1b4) [ 1.689453] [] (do_one_initcall+0x58/0x1b4) from [] (kernel_init+0x98/0x150) [ 1.698272] [] (kernel_init+0x98/0x150) from [] (kernel_thread_exit+0x0/0x8) [ 1.707214] ---[ end trace 6559b322ad3cbdfe ]--- [ 1.718292] twl4030_keypad: probe of twl4030_keypad failed with error -16 Signed-off-by: G, Manjunath Kondaiah Signed-off-by: Ameya Palande Cc: Tony Lindgren --- drivers/input/keyboard/twl4030_keypad.c | 16 +++++++++------- 1 files changed, 9 insertions(+), 7 deletions(-) diff --git a/drivers/input/keyboard/twl4030_keypad.c b/drivers/input/keyboard/twl4030_keypad.c index fb16b5e..cf94850 100644 --- a/drivers/input/keyboard/twl4030_keypad.c +++ b/drivers/input/keyboard/twl4030_keypad.c @@ -345,10 +345,13 @@ static int __devinit twl4030_kp_probe(struct platform_device *pdev) } kp = kzalloc(sizeof(*kp), GFP_KERNEL); + if (!kp) + return -ENOMEM; + input = input_allocate_device(); - if (!kp || !input) { - error = -ENOMEM; - goto err1; + if (!input) { + kfree(kp); + return -ENOMEM; } /* Get the debug Device */ @@ -406,23 +409,22 @@ static int __devinit twl4030_kp_probe(struct platform_device *pdev) if (error) { dev_info(kp->dbg_dev, "request_irq failed for irq no=%d\n", kp->irq); - goto err3; + goto err2; } /* Enable KP and TO interrupts now. */ reg = (u8) ~(KEYP_IMR1_KP | KEYP_IMR1_TO); if (twl4030_kpwrite_u8(kp, reg, KEYP_IMR1)) { error = -EIO; - goto err4; + goto err3; } platform_set_drvdata(pdev, kp); return 0; -err4: +err3: /* mask all events - we don't care about the result */ (void) twl4030_kpwrite_u8(kp, 0xff, KEYP_IMR1); -err3: free_irq(kp->irq, NULL); err2: input_unregister_device(input); -- 1.7.0.4