[PATCH] ASoC: codecs: lpass-rx-macro: Check for error pointer after calling devm_regmap_init_mmio

From: Jiasheng Jiang
Date: Mon Jan 10 2022 - 02:12:24 EST


The devm_regmap_init_mmio() may return error pointer under certain
circumstances, for example the possible failure of the kzalloc() in
regmap_mmio_gen_context(), which is called by devm_regmap_init_mmio().
Then the rx->regmap will be error pointer and be used in
rx_macro_mclk_enable().
Therefore, it should be better to check it in order to avoid the
dereference of the error pointer.

Fixes: af3d54b99764 ("ASoC: codecs: lpass-rx-macro: add support for lpass rx macro")
Signed-off-by: Jiasheng Jiang <jiasheng@xxxxxxxxxxx>
---
sound/soc/codecs/lpass-rx-macro.c | 2 ++
1 file changed, 2 insertions(+)

diff --git a/sound/soc/codecs/lpass-rx-macro.c b/sound/soc/codecs/lpass-rx-macro.c
index 07894ec5e7a6..2adbf2e2697f 100644
--- a/sound/soc/codecs/lpass-rx-macro.c
+++ b/sound/soc/codecs/lpass-rx-macro.c
@@ -3542,6 +3542,8 @@ static int rx_macro_probe(struct platform_device *pdev)
return PTR_ERR(base);

rx->regmap = devm_regmap_init_mmio(dev, base, &rx_regmap_config);
+ if (IS_ERR(rx->regmap))
+ return PTR_ERR(rx->regmap);

dev_set_drvdata(dev, rx);

--
2.25.1