Skip to contentSkip to conversation

ASoC: rockchip: i2s: Fix crash on missing pinctrl

PATCH In review Chen-Yu Tsai 2 participants 2 messages Jun 21, 2022 – Jun 22, 2022

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ASoC: rockchip: i2s: Fix crash on missing pinctrl

From: Chen-Yu Tsai <[email protected]>

Commit 44f362c2cc6d ("ASoC: rockchip: i2s: switch BCLK to GPIO") added pinctrl lookups, but did not skip the lookup if there was no pinctrl device tied to the I2S controller. As a result, the lookup was done on an invalid pointer in such cases, causing a kernel panic.

Only do the subsequent pinctrl state lookups and switch if a pinctrl device was found.

i2s_pinctrl_select_bclk_{on,off} already guard against missing pinctrl device or pinctrl state, so those two functions aren't touched.

Fixes 44f362c2cc6d ("ASoC: rockchip: i2s: switch BCLK to GPIO")

---

This is based on next-20220621, which just saw the inclusion of the commit this patch fixes.

This issue was found and tested on ROC-RK3328-CC. Tried to test on RK3399, but that has some other DRM driver related crash.

 sound/soc/rockchip/rockchip_i2s.c | 29 ++++++++++++++---------------
 1 file changed, 14 insertions(+), 15 deletions(-)
sound/soc/rockchip/rockchip_i2s.c +14 -15
index be051e48b97b..9fa8ffd712ea 100644
@@ -808,24 +808,23 @@ static int rockchip_i2s_probe(struct platform_device *pdev)
 
 	i2s->bclk_ratio = 64;
 	i2s->pinctrl = devm_pinctrl_get(&pdev->dev);
-	if (IS_ERR(i2s->pinctrl))
+	if (IS_ERR(i2s->pinctrl)) {
 		dev_err(&pdev->dev, "failed to find i2s pinctrl\n");
+	} else {
+		i2s->bclk_on = pinctrl_lookup_state(i2s->pinctrl, "bclk_on");
+		if (IS_ERR_OR_NULL(i2s->bclk_on))
+			dev_err(&pdev->dev, "failed to find i2s default state\n");
+		else
+			dev_dbg(&pdev->dev, "find i2s bclk state\n");
 
-	i2s->bclk_on = pinctrl_lookup_state(i2s->pinctrl,
-				   "bclk_on");
-	if (IS_ERR_OR_NULL(i2s->bclk_on))
-		dev_err(&pdev->dev, "failed to find i2s default state\n");
-	else
-		dev_dbg(&pdev->dev, "find i2s bclk state\n");
-
-	i2s->bclk_off = pinctrl_lookup_state(i2s->pinctrl,
-				  "bclk_off");
-	if (IS_ERR_OR_NULL(i2s->bclk_off))
-		dev_err(&pdev->dev, "failed to find i2s gpio state\n");
-	else
-		dev_dbg(&pdev->dev, "find i2s bclk_off state\n");
+		i2s->bclk_off = pinctrl_lookup_state(i2s->pinctrl, "bclk_off");
+		if (IS_ERR_OR_NULL(i2s->bclk_off))
+			dev_err(&pdev->dev, "failed to find i2s gpio state\n");
+		else
+			dev_dbg(&pdev->dev, "find i2s bclk_off state\n");
 
-	i2s_pinctrl_select_bclk_off(i2s);
+		i2s_pinctrl_select_bclk_off(i2s);
+	}
 
 	i2s->playback_dma_data.addr = res->start + I2S_TXDR;
 	i2s->playback_dma_data.addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES;
Signature · 7 lines
2.34.1


_______________________________________________
Linux-rockchip mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-rockchip
maintainer
#1 lore raw
Quoted 8 lines · Chen-Yu Tsai

From: Chen-Yu Tsai <[email protected]>

Commit 44f362c2cc6d ("ASoC: rockchip: i2s: switch BCLK to GPIO") added pinctrl lookups, but did not skip the lookup if there was no pinctrl device tied to the I2S controller. As a result, the lookup was done on an invalid pointer in such cases, causing a kernel panic.

[...]

Applied to

https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next

Thanks!

[1/1] ASoC: rockchip: i2s: Fix crash on missing pinctrl

      commit: c3b5fd7fbb698496461f280728b456d9927f22af

All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying to this mail.

Thanks,
Mark