Skip to content

regmap: Fix bus context frees on init failure

Arun Iyengar b4-sent driver-core linux-hwmon lkml 1 version In review

Get series with b4
b4 am [email protected] change-id 20261129-regmap-devm-ctx-2955bb2c1077

Versions newest first

  1. v1 Latest2 patches 2 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/2regmap: Don't free the bus context when devm init failsdrivers/base/regmap/regmap.c+12 -80 replies
2/2regmap: mmio: Free the context if regmap init failsdrivers/base/regmap/regmap-mmio.c+14 -40 replies

Reviews trailers per patch

None of the 2 patches has a Reviewed-by or Acked-by of their own; the series has one for all of them.

PatchPeng Fan
SeriesR-b
1/2
2/2

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v1 thread

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

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,

Signature · 1 line
Arun Iyengar <[email protected]>