Skip to content

Commit

Permalink
ASoC: rockchip: i2s: Fix NULL pointer dereference when pinctrl is not…
Browse files Browse the repository at this point in the history
… found

Commit a5450ab ("ASoC: rockchip: i2s: switch BCLK to GPIO") switched
BCLK to GPIO functions when probing the i2s bus interface, but missed
adding a check for when devm_pinctrl_get() returns an error.  This can lead
to the following NULL pointer dereference on a rockpro64-v2 if there are no
"pinctrl" properties in the i2s device tree node.

Check that i2s->pinctrl is valid before attempting to search for the
bclk_on and bclk_off pinctrl states.

Fixes: a5450ab ("ASoC: rockchip: i2s: switch BCLK to GPIO")
Signed-off-by: Alexandru Elisei <alexandru.elisei@arm.com>
Link: https://lore.kernel.org/r/20220711130522.401551-1-alexandru.elisei@arm.com
Signed-off-by: Mark Brown <broonie@kernel.org>
  • Loading branch information
Alexandru Elisei authored and Mark Brown committed Jul 11, 2022
1 parent fc976f5 commit 26b9f2f
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion sound/soc/rockchip/rockchip_i2s.c
Original file line number Diff line number Diff line change
Expand Up @@ -808,8 +808,11 @@ 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");
ret = PTR_ERR(i2s->pinctrl);
goto err_clk;
}

i2s->bclk_on = pinctrl_lookup_state(i2s->pinctrl,
"bclk_on");
Expand Down

0 comments on commit 26b9f2f

Please sign in to comment.