[PATCH 6.12 345/567] ASoC: codecs: wcd939x: fix regmap leak on probe failure

Greg Kroah-Hartman
2026-01-06T17:33:25Z

From: Johan Hovold <johan@kernel.org>

commit 86dc090f737953f16f8dc60c546ae7854690d4f6 upstream.

The soundwire regmap that may be allocated during probe is not freed on
late probe failures.

Add the missing error handling.

Fixes: be2af391cea0 ("ASoC: codecs: Add WCD939x Soundwire devices driver")
Cc: stable@vger.kernel.org # 6.9
Cc: Neil Armstrong <neil.armstrong@linaro.org>
Signed-off-by: Johan Hovold <johan@kernel.org>
Link: https://patch.msgid.link/20251127135057.2216-1-johan@kernel.org
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
sound/soc/codecs/wcd939x-sdw.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)

--- a/sound/soc/codecs/wcd939x-sdw.c
+++ b/sound/soc/codecs/wcd939x-sdw.c
@@ -1480,12 +1480,18 @@ static int wcd9390_probe(struct sdw_slav

ret = component_add(dev, &wcd939x_sdw_component_ops);
if (ret)
- return ret;
+ goto err_free_regmap;

/* Set suspended until aggregate device is bind */
pm_runtime_set_suspended(dev);

return 0;
+
+err_free_regmap:
+ if (wcd->regmap)
+ regmap_exit(wcd->regmap);
+
+ return ret;
}

static int wcd9390_remove(struct sdw_slave *pdev)