The AT24 driver might register some i2c devices using i2c_new_dummy().
These are freed in the error path, but not unregistered which leads to
memory corruptions later.

Signed-off-by: Sascha Hauer <[email protected]>
---
 drivers/eeprom/at24.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/eeprom/at24.c b/drivers/eeprom/at24.c
index 508ddbc7b3..06a2a4b226 100644
--- a/drivers/eeprom/at24.c
+++ b/drivers/eeprom/at24.c
@@ -496,8 +496,11 @@ static int at24_probe(struct device *dev)
 
 err_devfs_create:
 err_clients:
-       for (i = 1; i < num_addresses; i++)
+       for (i = 1; i < num_addresses; i++) {
+               if (at24->client[i])
+                       i2c_unregister_device(at24->client[i]);
                kfree(at24->client[i]);
+       }
 
        if (gpio_is_valid(at24->wp_gpio))
                gpio_free(at24->wp_gpio);
-- 
2.47.3


Reply via email to