[PATCH] ASoC: max9860: Register the supply notifier after initializing regmap
From: Haowen Tu
Date: Tue Nov 17 2026 - 22:33:12 EST
The DVDDIO notifier accesses max9860->regmap when the supply is disabled,
but probe registers it before initializing the regmap. If
devm_regmap_init_i2c() fails, the error path disables DVDDIO with an error
pointer stored in max9860->regmap. When the supply is switched off, the
notifier passes this pointer to the regcache helpers.
Register the notifier only after regmap initialization has succeeded.
This also makes devres unregister the notifier before releasing the
regmap, so the callback cannot outlive the resource it accesses.
Fixes: 3b2af7f79968 ("ASoC: max9860: new driver")
Signed-off-by: Haowen Tu <tuhaowen@xxxxxxxxxxxxx>
---
sound/soc/codecs/max9860.c | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/sound/soc/codecs/max9860.c b/sound/soc/codecs/max9860.c
index a25f6891fe2f..f05f26d477c7 100644
--- a/sound/soc/codecs/max9860.c
+++ b/sound/soc/codecs/max9860.c
@@ -630,13 +630,6 @@ static int max9860_probe(struct i2c_client *i2c)
return dev_err_probe(dev, PTR_ERR(max9860->dvddio),
"Failed to get DVDDIO supply\n");
- max9860->dvddio_nb.notifier_call = max9860_dvddio_event;
-
- ret = devm_regulator_register_notifier(max9860->dvddio,
- &max9860->dvddio_nb);
- if (ret)
- dev_err(dev, "Failed to register DVDDIO notifier: %d\n", ret);
-
ret = regulator_enable(max9860->dvddio);
if (ret != 0) {
dev_err(dev, "Failed to enable DVDDIO: %d\n", ret);
@@ -649,6 +642,13 @@ static int max9860_probe(struct i2c_client *i2c)
goto err_regulator;
}
+ max9860->dvddio_nb.notifier_call = max9860_dvddio_event;
+
+ ret = devm_regulator_register_notifier(max9860->dvddio,
+ &max9860->dvddio_nb);
+ if (ret)
+ dev_err(dev, "Failed to register DVDDIO notifier: %d\n", ret);
+
dev_set_drvdata(dev, max9860);
/*
--
2.50.1