Building the Linux kernel with Clang and LLVM
 help / color / mirror / Atom feed
* [PATCH 0/2] ASoC: mediatek: clear afe->regmap on devm_regmap_init_mmio() error
@ 2026-11-20 19:22 Elkin Cruz
  2026-11-20 19:22 ` [PATCH 1/2] ASoC: mediatek: mt8196: " Elkin Cruz
  2026-11-20 19:22 ` [PATCH 2/2] ASoC: mediatek: mt8189: " Elkin Cruz
  0 siblings, 2 replies; 3+ messages in thread
From: Elkin Cruz @ 2026-11-20 19:22 UTC (permalink / raw)
  To: Liam Girdwood, Mark Brown, Jaroslav Kysela, Takashi Iwai,
	Matthias Brugger, AngeloGioacchino Del Regno
  Cc: linux-sound, linux-kernel, linux-arm-kernel, linux-mediatek, llvm,
	irogers, Elkin Cruz

I am trying out a new Clang static analysis linter for ERR_PTR/NULL
handling, and it flagged this code as possibly buggy. The findings were triaged
and fixed with an AI coding assistant, then checked against linux-next (not
runtime-tested on hardware).

Thanks,
Elkin

Elkin Cruz (2):
  ASoC: mediatek: mt8196: clear afe->regmap on devm_regmap_init_mmio()
    error
  ASoC: mediatek: mt8189: clear afe->regmap on devm_regmap_init_mmio()
    error

 sound/soc/mediatek/mt8189/mt8189-afe-pcm.c | 1 +
 sound/soc/mediatek/mt8196/mt8196-afe-pcm.c | 1 +
 2 files changed, 2 insertions(+)

-- 
2.56.1.750.gf70dc682cf-goog


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH 1/2] ASoC: mediatek: mt8196: clear afe->regmap on devm_regmap_init_mmio() error
  2026-11-20 19:22 [PATCH 0/2] ASoC: mediatek: clear afe->regmap on devm_regmap_init_mmio() error Elkin Cruz
@ 2026-11-20 19:22 ` Elkin Cruz
  2026-11-20 19:22 ` [PATCH 2/2] ASoC: mediatek: mt8189: " Elkin Cruz
  1 sibling, 0 replies; 3+ messages in thread
From: Elkin Cruz @ 2026-11-20 19:22 UTC (permalink / raw)
  To: Liam Girdwood, Mark Brown, Jaroslav Kysela, Takashi Iwai,
	Matthias Brugger, AngeloGioacchino Del Regno
  Cc: linux-sound, linux-kernel, linux-arm-kernel, linux-mediatek, llvm,
	irogers, Elkin Cruz

When devm_regmap_init_mmio() fails in mt8196_afe_pcm_dev_probe(),
afe->regmap holds an ERR_PTR() while unwinding through err_pm_put ->
pm_runtime_put_sync(), which invokes mt8196_afe_runtime_suspend().
Because mt8196_afe_runtime_suspend() only guards if (!afe->regmap), it
passes the error pointer into regcache_cache_only() and crashes.

Clear afe->regmap to NULL before jumping to err_pm_put.

Fixes: e38353138a09 ("ASoC: mediatek: mt8196: Fix probe resource cleanup")
Signed-off-by: Elkin Cruz <elkin@google.com>
---
 sound/soc/mediatek/mt8196/mt8196-afe-pcm.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/sound/soc/mediatek/mt8196/mt8196-afe-pcm.c b/sound/soc/mediatek/mt8196/mt8196-afe-pcm.c
index 82b5ae91751a..3028aa82c4a8 100644
--- a/sound/soc/mediatek/mt8196/mt8196-afe-pcm.c
+++ b/sound/soc/mediatek/mt8196/mt8196-afe-pcm.c
@@ -2450,6 +2450,7 @@ static int mt8196_afe_pcm_dev_probe(struct platform_device *pdev)
 					    &mt8196_afe_regmap_config);
 	if (IS_ERR(afe->regmap)) {
 		ret = PTR_ERR(afe->regmap);
+		afe->regmap = NULL;
 		goto err_pm_put;
 	}
 
-- 
2.56.1.750.gf70dc682cf-goog


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH 2/2] ASoC: mediatek: mt8189: clear afe->regmap on devm_regmap_init_mmio() error
  2026-11-20 19:22 [PATCH 0/2] ASoC: mediatek: clear afe->regmap on devm_regmap_init_mmio() error Elkin Cruz
  2026-11-20 19:22 ` [PATCH 1/2] ASoC: mediatek: mt8196: " Elkin Cruz
@ 2026-11-20 19:22 ` Elkin Cruz
  1 sibling, 0 replies; 3+ messages in thread
From: Elkin Cruz @ 2026-11-20 19:22 UTC (permalink / raw)
  To: Liam Girdwood, Mark Brown, Jaroslav Kysela, Takashi Iwai,
	Matthias Brugger, AngeloGioacchino Del Regno
  Cc: linux-sound, linux-kernel, linux-arm-kernel, linux-mediatek, llvm,
	irogers, Elkin Cruz

When devm_regmap_init_mmio() fails in mt8189_afe_pcm_dev_probe(),
afe->regmap holds an ERR_PTR() while unwinding through err_pm_put ->
pm_runtime_put_sync(), which invokes mt8189_afe_runtime_suspend().
Because mt8189_afe_runtime_suspend() only checks if (!afe->regmap), the
ERR_PTR() value is passed to regmap_write() and regcache_cache_only().

Clear afe->regmap to NULL before jumping to err_pm_put.

Fixes: 5404599c3292 ("ASoC: mediatek: mt8189: Fix probe resource cleanup")
Signed-off-by: Elkin Cruz <elkin@google.com>
---
 sound/soc/mediatek/mt8189/mt8189-afe-pcm.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/sound/soc/mediatek/mt8189/mt8189-afe-pcm.c b/sound/soc/mediatek/mt8189/mt8189-afe-pcm.c
index f39b01590f71..85b5be6d45ec 100644
--- a/sound/soc/mediatek/mt8189/mt8189-afe-pcm.c
+++ b/sound/soc/mediatek/mt8189/mt8189-afe-pcm.c
@@ -2563,6 +2563,7 @@ static int mt8189_afe_pcm_dev_probe(struct platform_device *pdev)
 					    &mt8189_afe_regmap_config);
 	if (IS_ERR(afe->regmap)) {
 		ret = PTR_ERR(afe->regmap);
+		afe->regmap = NULL;
 		goto err_pm_put;
 	}
 
-- 
2.56.1.750.gf70dc682cf-goog


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-11-20 19:24 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-20 19:22 [PATCH 0/2] ASoC: mediatek: clear afe->regmap on devm_regmap_init_mmio() error Elkin Cruz
2026-11-20 19:22 ` [PATCH 1/2] ASoC: mediatek: mt8196: " Elkin Cruz
2026-11-20 19:22 ` [PATCH 2/2] ASoC: mediatek: mt8189: " Elkin Cruz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox