From b588d829ad7620e62ce9112273bfdb2e4a2d4adb Mon Sep 17 00:00:00 2001 From: xsang Date: Fri, 19 Jun 2020 19:46:57 +0800 Subject: [PATCH] asoc: add null check for pcm pointer of snd_pcm_volume In platform driver volume controls, add null check for pcm pointer of struct snd_pcm_volume. Change-Id: I511a79422eaeced6240849cbb665a289afdc5984 Signed-off-by: Xiaojun Sang --- asoc/msm-pcm-q6-noirq.c | 6 ++++++ asoc/msm-pcm-q6-v2.c | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/asoc/msm-pcm-q6-noirq.c b/asoc/msm-pcm-q6-noirq.c index 47b48a2c34f2..59520581b8ef 100644 --- a/asoc/msm-pcm-q6-noirq.c +++ b/asoc/msm-pcm-q6-noirq.c @@ -732,6 +732,12 @@ 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__); diff --git a/asoc/msm-pcm-q6-v2.c b/asoc/msm-pcm-q6-v2.c index 37369f67377b..5762a95edbb3 100644 --- a/asoc/msm-pcm-q6-v2.c +++ b/asoc/msm-pcm-q6-v2.c @@ -1530,6 +1530,12 @@ 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__);