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 <jonathanh@nvidia.com>
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 <bbasu@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
This commit is contained in:
Jonathan Hunter
2019-05-16 13:48:06 +01:00
committed by Sameer Pujar
parent 52f2d67cf4
commit e34a9de325
3 changed files with 6 additions and 6 deletions

View File

@@ -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) {