mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
To: barebox@lists.infradead.org
Subject: [PATCH 2/3] eeprom: at24: check return value of devfs_create and fix error path
Date: Mon, 30 May 2016 11:39:52 +0200	[thread overview]
Message-ID: <1464601193-20832-2-git-send-email-u.kleine-koenig@pengutronix.de> (raw)
In-Reply-To: <1464601193-20832-1-git-send-email-u.kleine-koenig@pengutronix.de>

if devfs_create failed because "eeprom0" already exists
of_parse_partitions must not be called, otherwise the already existing
eeprom gets assigned partitions that don't belog there.

Also free dummy clients in the error path and the write protect gpio
only if it is actually valid.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
 drivers/eeprom/at24.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/drivers/eeprom/at24.c b/drivers/eeprom/at24.c
index a323d25dd494..0f54d1b6de50 100644
--- a/drivers/eeprom/at24.c
+++ b/drivers/eeprom/at24.c
@@ -480,14 +480,21 @@ static int at24_probe(struct device_d *dev)
 		}
 	}
 
-	devfs_create(&at24->cdev);
+	err = devfs_create(&at24->cdev);
+	if (err)
+		goto err_devfs_create;
 
 	of_parse_partitions(&at24->cdev, dev->device_node);
 
 	return 0;
 
+err_devfs_create:
 err_clients:
-	gpio_free(at24->wp_gpio);
+	for (i = 1; i < num_addresses; i++)
+		kfree(at24->client[i]);
+
+	if (gpio_is_valid(at24->wp_gpio))
+		gpio_free(at24->wp_gpio);
 	kfree(at24->writebuf);
 	kfree(at24);
 err_out:
-- 
2.8.1


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

  reply	other threads:[~2016-05-30  9:40 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-30  9:39 [PATCH 1/3] eeprom: at25: check return value of devfs_create Uwe Kleine-König
2016-05-30  9:39 ` Uwe Kleine-König [this message]
2016-05-30  9:39 ` [PATCH 3/3] eeprom: at24: make device name setup more robust Uwe Kleine-König
2016-05-31  6:58 ` [PATCH 1/3] eeprom: at25: check return value of devfs_create 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=1464601193-20832-2-git-send-email-u.kleine-koenig@pengutronix.de \
    --to=u.kleine-koenig@pengutronix.de \
    --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