[PATCH 2/3] eeprom: at24: check return value of devfs_create and fix error path

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxxxx>
---
 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@xxxxxxxxxxxxxxxxxxx
http://lists.infradead.org/mailman/listinfo/barebox




[Index of Archives]     [Linux Embedded]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux