From: Sascha Hauer <s.hauer@pengutronix.de>
To: Barebox List <barebox@lists.infradead.org>
Subject: [PATCH 3/3] eeprom: at24: unregister devices in error path
Date: Wed, 17 Dec 2025 15:51:55 +0100 [thread overview]
Message-ID: <20251217145156.1581678-3-s.hauer@pengutronix.de> (raw)
In-Reply-To: <20251217145156.1581678-1-s.hauer@pengutronix.de>
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 <s.hauer@pengutronix.de>
---
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
prev parent reply other threads:[~2025-12-17 14:52 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-17 14:51 [PATCH 1/3] of: replace of_alias_get_highest_id() with of_alias_get_free_id() Sascha Hauer
2025-12-17 14:51 ` [PATCH 2/3] i2c: implement i2c_unregister_device() Sascha Hauer
2025-12-17 14:51 ` Sascha Hauer [this message]
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=20251217145156.1581678-3-s.hauer@pengutronix.de \
--to=s.hauer@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