From patchwork Tue Sep 7 13:24:03 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ameya Palande X-Patchwork-Id: 160551 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id o87DO9E2018437 for ; Tue, 7 Sep 2010 13:24:09 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755267Ab0IGNYI (ORCPT ); Tue, 7 Sep 2010 09:24:08 -0400 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 Received: from localhost.localdomain (esdhcp03630.research.nokia.com [172.21.36.30]) by mgw-sa02.nokia.com (Switch-3.4.3/Switch-3.4.3) with ESMTP id o87DO4Th013445; Tue, 7 Sep 2010 16:24:04 +0300 From: Ameya Palande To: linux-omap@vger.kernel.org Cc: tony@atomide.com, manjugk@ti.com 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> X-Mailer: git-send-email 1.7.0.4 In-Reply-To: <1283860305-22585-1-git-send-email-manjugk@ti.com> References: <1283860305-22585-1-git-send-email-manjugk@ti.com> X-Nokia-AV: Clean Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter1.kernel.org [140.211.167.41]); Tue, 07 Sep 2010 13:24:09 +0000 (UTC) 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);