[PATCH] i2c: atr: Fix potential alias mapping leak on adapter removal
From: Guangshuo Li
Date: Thu Nov 12 2026 - 10:25:24 EST
Transfers to addresses without registered clients can create alias
mappings. Removing the adapter generates no client removal notification
for those addresses, so their mappings and alias reservations remain.
Detach any remaining mappings after deleting the adapter and before
freeing its alias pool and channel.
This issue was found by our static analysis tool under development.
Fixes: c3f55241882b ("i2c: Support dynamic address translation")
Cc: stable@xxxxxxxxxxxxxxx
Signed-off-by: Guangshuo Li <liguangshuo@xxxxxxxxxxxxxxx>
---
drivers/i2c/i2c-atr.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/drivers/i2c/i2c-atr.c b/drivers/i2c/i2c-atr.c
index b98442ffff94..ebade2a000b2 100644
--- a/drivers/i2c/i2c-atr.c
+++ b/drivers/i2c/i2c-atr.c
@@ -903,6 +903,7 @@ EXPORT_SYMBOL_NS_GPL(i2c_atr_add_adapter, "I2C_ATR");
void i2c_atr_del_adapter(struct i2c_atr *atr, u32 chan_id)
{
+ struct i2c_atr_alias_pair *c2a, *tmp;
char symlink_name[ATR_MAX_SYMLINK_LEN];
struct i2c_adapter *adap;
struct i2c_atr_chan *chan;
@@ -925,6 +926,9 @@ void i2c_atr_del_adapter(struct i2c_atr *atr, u32 chan_id)
i2c_del_adapter(adap);
+ list_for_each_entry_safe(c2a, tmp, &chan->alias_pairs, node)
+ i2c_atr_detach_addr(adap, c2a->addr);
+
if (!chan->alias_pool->shared)
i2c_atr_free_alias_pool(chan->alias_pool);
base-commit: 6628e7d4c6b25c8d18f1345e3a20d21829aae7e4
--
2.43.0