From e34a9de325bb27105e1bf00623d5094458d6ce4d Mon Sep 17 00:00:00 2001 From: Jonathan Hunter Date: Thu, 16 May 2019 13:48:06 +0100 Subject: [PATCH] ASoC: tegra-alt: Check if pinctrl state is NULL If the pinctrl node is not present in device-tree for the DMIC, DSPK or I2S, then the pinctrl states will not be initialised during device probe. This can cause the kernel to crash by attempting to dereference a NULL pointer when setting the pinctrl state. Fix this by verifying that the pinctrl state is not an error pointer or NULL before attempting to use it. Bug 1665446 Change-Id: I917141325f12bbf87371eb59a320fe08e65f0934 Signed-off-by: Jonathan Hunter Reviewed-on: https://git-master.nvidia.com/r/2120320 (cherry picked from commit f3aa620e26af45a6bafe5acb65f2b06df0b877e8) Reviewed-on: https://git-master.nvidia.com/r/2122730 Reviewed-by: Automatic_Commit_Validation_User GVS: Gerrit_Virtual_Submit Reviewed-by: Bibek Basu Reviewed-by: mobile promotions Tested-by: mobile promotions --- sound/soc/tegra-alt/tegra186_dspk_alt.c | 4 ++-- sound/soc/tegra-alt/tegra210_dmic_alt.c | 4 ++-- sound/soc/tegra-alt/tegra210_i2s_alt.c | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/sound/soc/tegra-alt/tegra186_dspk_alt.c b/sound/soc/tegra-alt/tegra186_dspk_alt.c index fe13f1b6..784e26e9 100644 --- a/sound/soc/tegra-alt/tegra186_dspk_alt.c +++ b/sound/soc/tegra-alt/tegra186_dspk_alt.c @@ -187,7 +187,7 @@ static int tegra186_dspk_startup(struct snd_pcm_substream *substream, } if (!(tegra_platform_is_unit_fpga() || tegra_platform_is_fpga())) { - if (!IS_ERR(dspk->pin_active_state)) { + if (!IS_ERR_OR_NULL(dspk->pin_active_state)) { ret = pinctrl_select_state(dspk->pinctrl, dspk->pin_active_state); if (ret < 0) { @@ -209,7 +209,7 @@ static void tegra186_dspk_shutdown(struct snd_pcm_substream *substream, int ret; if (!(tegra_platform_is_unit_fpga() || tegra_platform_is_fpga())) { - if (!IS_ERR(dspk->pin_idle_state)) { + if (!IS_ERR_OR_NULL(dspk->pin_idle_state)) { ret = pinctrl_select_state( dspk->pinctrl, dspk->pin_idle_state); if (ret < 0) { diff --git a/sound/soc/tegra-alt/tegra210_dmic_alt.c b/sound/soc/tegra-alt/tegra210_dmic_alt.c index f807214a..fdc91447 100644 --- a/sound/soc/tegra-alt/tegra210_dmic_alt.c +++ b/sound/soc/tegra-alt/tegra210_dmic_alt.c @@ -223,7 +223,7 @@ static int tegra210_dmic_startup(struct snd_pcm_substream *substream, } if (!(tegra_platform_is_unit_fpga() || tegra_platform_is_fpga())) { - if (!IS_ERR(dmic->pin_active_state)) { + if (!IS_ERR_OR_NULL(dmic->pin_active_state)) { ret = pinctrl_select_state(dmic->pinctrl, dmic->pin_active_state); if (ret < 0) { @@ -244,7 +244,7 @@ static void tegra210_dmic_shutdown(struct snd_pcm_substream *substream, int ret; if (!(tegra_platform_is_unit_fpga() || tegra_platform_is_fpga())) { - if (!IS_ERR(dmic->pin_idle_state)) { + if (!IS_ERR_OR_NULL(dmic->pin_idle_state)) { ret = pinctrl_select_state( dmic->pinctrl, dmic->pin_idle_state); if (ret < 0) diff --git a/sound/soc/tegra-alt/tegra210_i2s_alt.c b/sound/soc/tegra-alt/tegra210_i2s_alt.c index ddb0d9b2..6f23c5c5 100644 --- a/sound/soc/tegra-alt/tegra210_i2s_alt.c +++ b/sound/soc/tegra-alt/tegra210_i2s_alt.c @@ -496,7 +496,7 @@ static int tegra210_i2s_startup(struct snd_pcm_substream *substream, } } - if (!IS_ERR(i2s->pin_default_state)) { + if (!IS_ERR_OR_NULL(i2s->pin_default_state)) { ret = pinctrl_select_state(i2s->pinctrl, i2s->pin_default_state); if (ret < 0) { @@ -525,7 +525,7 @@ static void tegra210_i2s_shutdown(struct snd_pcm_substream *substream, int ret; if (!(tegra_platform_is_unit_fpga() || tegra_platform_is_fpga())) { - if (!IS_ERR(i2s->pin_idle_state)) { + if (!IS_ERR_OR_NULL(i2s->pin_idle_state)) { ret = pinctrl_select_state( i2s->pinctrl, i2s->pin_idle_state); if (ret < 0) {