From 3982f4ad8a3d755959d36905d1528a6820faadfe Mon Sep 17 00:00:00 2001 From: Uwe Kleine-König Date: Mon, 30 May 2016 11:39:52 +0200 Subject: eeprom: at24: check return value of devfs_create and fix error path MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Signed-off-by: Sascha Hauer --- drivers/eeprom/at24.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'drivers/eeprom') diff --git a/drivers/eeprom/at24.c b/drivers/eeprom/at24.c index a323d25dd4..0f54d1b6de 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: -- cgit v1.2.3