diff mbox

[PATCHv2] OMAP3: Keypad: Fix failure exit path in probe

Message ID 1283865843-10178-1-git-send-email-ameya.palande@nokia.com (mailing list archive)
State Awaiting Upstream, archived
Headers show

Commit Message

Ameya Palande Sept. 7, 2010, 1:24 p.m. UTC
None
diff mbox

Patch

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);