[PATCH 0/2] regmap: Fix bus context frees on init failure

From: Arun Iyengar via B4 Relay

Date: Mon Nov 30 2026 - 15:21:38 EST


Since b1ef855c6260, a failing __devm_regmap_init() can free the bus
context, so spi-avmm and sch56xx free it twice. Patch 1 restores the
old behaviour. Patch 2 fixes the mmio context leak on init failure.

Tested with failslab on an Orange Pi 5 (devm mmio regmap): kmemleak
finds the mmio leak, and with patch 2 alone KASAN reports the double
free. With both patches, no reports. spi-avmm and sch56xx were not run.

Developed with Claude (Anthropic), which wrote the code and the commit
messages. I reviewed every change.

---
Arun Iyengar (2):
regmap: Don't free the bus context when devm init fails
regmap: mmio: Free the context if regmap init fails

drivers/base/regmap/regmap-mmio.c | 18 ++++++++++++++----
drivers/base/regmap/regmap.c | 20 ++++++++++++--------
2 files changed, 26 insertions(+), 12 deletions(-)
---
base-commit: 222b61e9c570dac6c7a786d039e4c226624b426d
change-id: 20261129-regmap-devm-ctx-2955bb2c1077

Best regards,
--
Arun Iyengar <aiyengar1990@xxxxxxxxx>