rtc: isl12026: Fix EEPROM dummy client leak on probe failure
Subsystems (2)
PATCH 1/1 rtc: isl12026: Fix EEPROM dummy client leak on probe failure
isl12026_probe() registers a dummy i2c client for the EEPROM at 0x57 with i2c_new_dummy_device(), but only isl12026_remove() unregisters it. If devm_rtc_allocate_device(), devm_rtc_nvmem_register() or devm_rtc_register_device() fails, probe returns with the dummy client still registered. Every later probe attempt then fails with -EBUSY in i2c_new_dummy_device(), because 0x57 is still taken by the leaked client.
Use devm_i2c_new_dummy_device() and drop isl12026_remove(). The dummy client is now unregistered on probe failure, and on unbind it is unregistered after the devm-managed RTC and nvmem devices that use it.
---
Based on linux-next next-20261109 (630059a5a632).
Compile-tested: arm64, GCC 14.2.0, W=1, CONFIG_RTC_DRV_ISL12026=m, CONFIG_RTC_NVMEM=y, CONFIG_COMPILE_TEST=y (object only; no new warnings).
Runtime-tested in QEMU (arm64 virt, KASAN) with this driver on a test I2C adapter module: with fault injection failing probe after the EEPROM client exists, the next probe fails with -EBUSY on 0x57 before the patch and binds after it; unbind/rebind and module reload are clean. No hardware test. AI assistance was used for analysis and patch preparation.
Needs a probe error after the dummy client is created (allocation failure, or an nvmem or RTC registration error); no in-tree DT uses isil,isl12026.
drivers/rtc/rtc-isl12026.c | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-)
drivers/rtc/rtc-isl12026.c +2 -9
@@ -453,7 +453,8 @@ static int isl12026_probe(struct i2c_client *client)isl12026_force_power_modes (client); - priv->nvm_client =i2c_new_dummy_device (client->adapter,ISL12026_EEPROM_ADDR ); + priv->nvm_client =devm_i2c_new_dummy_device (&client->dev, client->adapter, +ISL12026_EEPROM_ADDR );if (IS_ERR (priv->nvm_client))return PTR_ERR (priv->nvm_client);
@@ -471,13 +472,6 @@ static int isl12026_probe(struct i2c_client *client)return devm_rtc_register_device (priv->rtc); } -static void isl12026_remove (struct i2c_client *client) -{ -struct isl12026 *priv =i2c_get_clientdata (client); - -i2c_unregister_device (priv->nvm_client); -} -static const struct of_device_id isl12026_dt_match[] = { { .compatible ="isil,isl12026" }, { }
@@ -496,7 +490,6 @@ static struct i2c_driver isl12026_driver = { .of_match_table = isl12026_dt_match, }, .probe = isl12026_probe, - .remove = isl12026_remove, .id_table = isl12026_id, };
base-commit: 630059a5a632377b9b7b487baccde92b7ae1dd47
[email protected]
AI reviewSashiko has reviewed this patch and found no issues.
Quoted 8 lines
isl12026_probe()registers a dummy i2c client for the EEPROM at0x57withi2c_new_dummy_device(), but onlyisl12026_remove()unregisters it. Ifdevm_rtc_allocate_device(),devm_rtc_nvmem_register()ordevm_rtc_register_device()fails, probe returns with the dummy client still registered. Every later probe attempt then fails with-EBUSYini2c_new_dummy_device(), because0x57is still taken by the leaked client.
Quoted 7 lines
Use
devm_i2c_new_dummy_device()and dropisl12026_remove(). The dummy client is now unregistered on probe failure, and on unbind it is unregistered after the devm-managed RTC and nvmem devices that use it.Fixes 4731a43169b7 ("rtc: isl12026: new driver.")Signed-off-by Yige Jiang <[email protected]>
Sashiko has reviewed this patch and found no issues.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1