From 748a29b92cc70c633eb067dc5c5ce86694bbfd29 Mon Sep 17 00:00:00 2001 From: Laxminath Kasam Date: Thu, 30 Jan 2020 19:07:58 +0530 Subject: [PATCH] asoc: Add null check for kctl private_data in volume controls In platform driver volume controls, add null check for kctl private data before access. CRs-Fixed: 2611397 Change-Id: I49bdac2bb780a7116e54c20bf5f0d01f13a53165 Signed-off-by: Laxminath Kasam --- asoc/msm-pcm-loopback-v2.c | 8 ++++++-- asoc/msm-pcm-q6-noirq.c | 8 ++++++-- asoc/msm-pcm-q6-v2.c | 8 ++++++-- 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/asoc/msm-pcm-loopback-v2.c b/asoc/msm-pcm-loopback-v2.c index dd710fd9ad60..2a48f19839c0 100644 --- a/asoc/msm-pcm-loopback-v2.c +++ b/asoc/msm-pcm-loopback-v2.c @@ -569,11 +569,15 @@ static int msm_pcm_volume_ctl_get(struct snd_kcontrol *kcontrol, { int rc = 0; struct snd_pcm_volume *vol = snd_kcontrol_chip(kcontrol); - struct snd_pcm_substream *substream = - vol->pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream; + struct snd_pcm_substream *substream = NULL; struct msm_pcm_loopback *prtd; pr_debug("%s\n", __func__); + if (!vol) { + pr_err("%s: vol is NULL\n", __func__); + return -ENODEV; + } + substream = vol->pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream; if ((!substream) || (!substream->runtime)) { pr_debug("%s substream or runtime not found\n", __func__); rc = -ENODEV; diff --git a/asoc/msm-pcm-q6-noirq.c b/asoc/msm-pcm-q6-noirq.c index 6ceebb3fe949..9c0cc4bd2425 100644 --- a/asoc/msm-pcm-q6-noirq.c +++ b/asoc/msm-pcm-q6-noirq.c @@ -722,13 +722,17 @@ static int msm_pcm_volume_ctl_get(struct snd_kcontrol *kcontrol, { struct snd_pcm_volume *vol = snd_kcontrol_chip(kcontrol); struct msm_plat_data *pdata = NULL; - struct snd_pcm_substream *substream = - vol->pcm->streams[vol->stream].substream; + struct snd_pcm_substream *substream = NULL; struct snd_soc_pcm_runtime *soc_prtd = NULL; struct snd_soc_component *component = NULL; struct msm_audio *prtd; pr_debug("%s\n", __func__); + if (!vol) { + pr_err("%s: vol is NULL\n", __func__); + return -ENODEV; + } + substream = vol->pcm->streams[vol->stream].substream; if (!substream) { pr_err("%s substream not found\n", __func__); return -ENODEV; diff --git a/asoc/msm-pcm-q6-v2.c b/asoc/msm-pcm-q6-v2.c index 1da9f7ecd88d..352c0a32fb1f 100644 --- a/asoc/msm-pcm-q6-v2.c +++ b/asoc/msm-pcm-q6-v2.c @@ -1520,13 +1520,17 @@ static int msm_pcm_volume_ctl_get(struct snd_kcontrol *kcontrol, { struct snd_pcm_volume *vol = snd_kcontrol_chip(kcontrol); struct msm_plat_data *pdata = NULL; - struct snd_pcm_substream *substream = - vol->pcm->streams[vol->stream].substream; + struct snd_pcm_substream *substream = NULL; struct snd_soc_pcm_runtime *soc_prtd = NULL; struct snd_soc_component *component = NULL; struct msm_audio *prtd; pr_debug("%s\n", __func__); + if (!vol) { + pr_err("%s: vol is NULL\n", __func__); + return -ENODEV; + } + substream = vol->pcm->streams[vol->stream].substream; if (!substream) { pr_err("%s substream not found\n", __func__); return -ENODEV;