diff options
author | xsang <xsang@codeaurora.org> | 2020-10-12 12:34:44 +0800 |
---|---|---|
committer | xsang <xsang@codeaurora.org> | 2020-10-12 16:09:06 +0800 |
commit | d792204ac810e9a36b3979a43b716a18767a7098 (patch) | |
tree | d0a170fe515612d31854b27236becdc897af299b | |
parent | 29b8ebb7438acf75441f131232a0f80b5d49e688 (diff) | |
download | msm-extra-d792204ac810e9a36b3979a43b716a18767a7098.tar.gz |
ASoC: add pointer check for pcm at volume get
Add pointer check before access in volume get method.
Change-Id: Id0d0515c27f3e72617d39edb2bf550bcbb74e0c9
Signed-off-by: xsang <xsang@codeaurora.org>
-rw-r--r-- | 4.0/asoc/msm-pcm-loopback-v2.c | 23 | ||||
-rw-r--r-- | 4.0/asoc/msm-pcm-q6-noirq.c | 26 | ||||
-rw-r--r-- | 4.0/asoc/msm-pcm-q6-v2.c | 27 | ||||
-rw-r--r-- | asoc/msm-pcm-q6-noirq.c | 16 | ||||
-rw-r--r-- | asoc/msm-pcm-q6-v2.c | 15 |
5 files changed, 91 insertions, 16 deletions
diff --git a/4.0/asoc/msm-pcm-loopback-v2.c b/4.0/asoc/msm-pcm-loopback-v2.c index 8ad8120c..c01cef2f 100644 --- a/4.0/asoc/msm-pcm-loopback-v2.c +++ b/4.0/asoc/msm-pcm-loopback-v2.c @@ -494,10 +494,21 @@ static int msm_pcm_volume_ctl_put(struct snd_kcontrol *kcontrol, { int rc = 0; struct snd_pcm_volume *vol = kcontrol->private_data; - struct snd_pcm_substream *substream = vol->pcm->streams[0].substream; + struct snd_pcm_substream *substream = NULL; struct msm_pcm_loopback *prtd; int volume = ucontrol->value.integer.value[0]; + if (!vol) { + pr_err("%s: vol is NULL\n", __func__); + return -ENODEV; + } + + if (!vol->pcm) { + pr_err("%s: vol->pcm is NULL\n", __func__); + return -ENODEV; + } + + substream = vol->pcm->streams[0].substream; pr_debug("%s: volume : 0x%x\n", __func__, volume); if ((!substream) || (!substream->runtime)) { pr_err("%s substream or runtime not found\n", __func__); @@ -522,8 +533,7 @@ 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__); @@ -531,6 +541,13 @@ static int msm_pcm_volume_ctl_get(struct snd_kcontrol *kcontrol, pr_err("%s: vol is NULL\n", __func__); return -ENODEV; } + + if (!vol->pcm) { + pr_err("%s: vol->pcm 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/4.0/asoc/msm-pcm-q6-noirq.c b/4.0/asoc/msm-pcm-q6-noirq.c index eb8a974e..b7585164 100644 --- a/4.0/asoc/msm-pcm-q6-noirq.c +++ b/4.0/asoc/msm-pcm-q6-noirq.c @@ -704,8 +704,7 @@ 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 msm_audio *prtd; @@ -714,6 +713,14 @@ static int msm_pcm_volume_ctl_get(struct snd_kcontrol *kcontrol, pr_err("%s: vol is NULL\n", __func__); return -ENODEV; } + + if (!vol->pcm) { + pr_err("%s: vol->pcm 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; @@ -745,12 +752,23 @@ static int msm_pcm_volume_ctl_put(struct snd_kcontrol *kcontrol, int rc = 0; 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 msm_audio *prtd; int volume = ucontrol->value.integer.value[0]; + pr_debug("%s\n", __func__); + if (!vol) { + pr_err("%s: vol is NULL\n", __func__); + return -ENODEV; + } + + if (!vol->pcm) { + pr_err("%s: vol->pcm is NULL\n", __func__); + return -ENODEV; + } + + substream = vol->pcm->streams[vol->stream].substream; pr_debug("%s: volume : 0x%x\n", __func__, volume); if (!substream) { pr_err("%s substream not found\n", __func__); diff --git a/4.0/asoc/msm-pcm-q6-v2.c b/4.0/asoc/msm-pcm-q6-v2.c index 507c0d85..db6b992c 100644 --- a/4.0/asoc/msm-pcm-q6-v2.c +++ b/4.0/asoc/msm-pcm-q6-v2.c @@ -1459,8 +1459,7 @@ 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 msm_audio *prtd; @@ -1469,6 +1468,14 @@ static int msm_pcm_volume_ctl_get(struct snd_kcontrol *kcontrol, pr_err("%s: vol is NULL\n", __func__); return -ENODEV; } + + if (!vol->pcm) { + pr_err("%s: vol->pcm 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; @@ -1500,14 +1507,24 @@ static int msm_pcm_volume_ctl_put(struct snd_kcontrol *kcontrol, { int rc = 0; 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 msm_plat_data *pdata = NULL; struct msm_audio *prtd; int volume = ucontrol->value.integer.value[0]; pr_debug("%s: volume : 0x%x\n", __func__, volume); + if (!vol) { + pr_err("%s: vol is NULL\n", __func__); + return -ENODEV; + } + + if (!vol->pcm) { + pr_err("%s: vol->pcm 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-noirq.c b/asoc/msm-pcm-q6-noirq.c index ab794657..7ef99e72 100644 --- a/asoc/msm-pcm-q6-noirq.c +++ b/asoc/msm-pcm-q6-noirq.c @@ -712,12 +712,24 @@ 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[SNDRV_PCM_STREAM_PLAYBACK].substream; + struct snd_pcm_substream *substream = NULL; struct snd_soc_pcm_runtime *soc_prtd = NULL; struct msm_audio *prtd; pr_debug("%s\n", __func__); + + if (!vol) { + pr_err("%s: vol is NULL\n", __func__); + return -ENODEV; + } + + if (!vol->pcm) { + pr_err("%s: vol->pcm is NULL\n", __func__); + return -ENODEV; + } + + substream = vol->pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].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 43a60d8c..6fd99faa 100644 --- a/asoc/msm-pcm-q6-v2.c +++ b/asoc/msm-pcm-q6-v2.c @@ -1382,12 +1382,23 @@ 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[SNDRV_PCM_STREAM_PLAYBACK].substream; + struct snd_pcm_substream *substream = NULL; struct snd_soc_pcm_runtime *soc_prtd = NULL; struct msm_audio *prtd; pr_debug("%s\n", __func__); + if (!vol) { + pr_err("%s: vol is NULL\n", __func__); + return -ENODEV; + } + + if (!vol->pcm) { + pr_err("%s: vol->pcm is NULL\n", __func__); + return -ENODEV; + } + + substream = vol->pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream; + if (!substream) { pr_err("%s substream not found\n", __func__); return -ENODEV; |