mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Alexander Shiyan <shc_work@mail.ru>
To: barebox@lists.infradead.org
Subject: [PATCH 10/12] imx_keypad: Fix error handling
Date: Sat, 12 Apr 2014 12:11:03 +0400	[thread overview]
Message-ID: <1397290265-21273-10-git-send-email-shc_work@mail.ru> (raw)
In-Reply-To: <1397290265-21273-1-git-send-email-shc_work@mail.ru>

Signed-off-by: Alexander Shiyan <shc_work@mail.ru>
---
 drivers/input/imx_keypad.c | 17 ++++++++---------
 1 file changed, 8 insertions(+), 9 deletions(-)

diff --git a/drivers/input/imx_keypad.c b/drivers/input/imx_keypad.c
index e6870df..a1e2055 100644
--- a/drivers/input/imx_keypad.c
+++ b/drivers/input/imx_keypad.c
@@ -392,17 +392,17 @@ static int __init imx_keypad_probe(struct device_d *dev)
 	struct console_device *cdev;
 	int error, i;
 
-	keypad = xzalloc(sizeof(struct imx_keypad));
-	if (!keypad) {
-		pr_err("not enough memory for driver data\n");
-		error = -ENOMEM;
-	}
-
 	if (!keymap_data) {
 		pr_err("no keymap defined\n");
 		return -ENODEV;
 	}
 
+	keypad = xzalloc(sizeof(struct imx_keypad));
+	if (!keypad) {
+		pr_err("not enough memory for driver data\n");
+		return -ENOMEM;
+	}
+
 	keypad->dev = dev;
 	keypad->mmio_base = dev_request_mem_region(dev, 0);
 
@@ -420,8 +420,8 @@ static int __init imx_keypad_probe(struct device_d *dev)
 	if (keypad->rows_en_mask > ((1 << MAX_MATRIX_KEY_ROWS) - 1) ||
 	   keypad->cols_en_mask > ((1 << MAX_MATRIX_KEY_COLS) - 1)) {
 		pr_err("invalid key data (too many rows or colums)\n");
-		error = -EINVAL;
-		//goto failed_clock_put;
+		free(keypad);
+		return -EINVAL;
 	}
 	pr_debug("enabled rows mask: %x\n", keypad->rows_en_mask);
 	pr_debug("enabled cols mask: %x\n", keypad->cols_en_mask);
@@ -446,7 +446,6 @@ static int __init imx_keypad_probe(struct device_d *dev)
 	console_register(&keypad->cdev);
 
 	return poller_register(&keypad->poller);
-
 }
 
 static struct driver_d imx_keypad_driver = {
-- 
1.8.3.2


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  parent reply	other threads:[~2014-04-12  8:11 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-04-12  8:10 [PATCH 01/12] scripts: imx-image: Fix resource leak Alexander Shiyan
2014-04-12  8:10 ` [PATCH 02/12] gui: " Alexander Shiyan
2014-04-12  8:10 ` [PATCH 03/12] lzo: Remove unused variable Alexander Shiyan
2014-04-12  8:10 ` [PATCH 04/12] ubifs: " Alexander Shiyan
2014-04-12  8:10 ` [PATCH 05/12] commands/mount: Return real error code if "mount" fail Alexander Shiyan
2014-04-23  9:47   ` Sascha Hauer
2014-04-12  8:10 ` [PATCH 06/12] commands/uimage: Fix error printing Alexander Shiyan
2014-04-12  8:11 ` [PATCH 07/12] commands/umount: Return real error code if "umount" fail Alexander Shiyan
2014-04-23  9:54   ` Sascha Hauer
2014-04-12  8:11 ` [PATCH 08/12] commands/usbserial: Remove unused variable Alexander Shiyan
2014-04-12  8:11 ` [PATCH 09/12] ata: pata-imx: " Alexander Shiyan
2014-04-12  8:11 ` Alexander Shiyan [this message]
2014-04-23  9:54   ` [PATCH 10/12] imx_keypad: Fix error handling Sascha Hauer
2014-04-12  8:11 ` [PATCH 11/12] mtd: partition: Remove unused variable Alexander Shiyan
2014-04-12  8:11 ` [PATCH 12/12] mtd: nand: bbt: " Alexander Shiyan
2014-04-23  9:56 ` [PATCH 01/12] scripts: imx-image: Fix resource leak Sascha Hauer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1397290265-21273-10-git-send-email-shc_work@mail.ru \
    --to=shc_work@mail.ru \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox