summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLinux Build Service Account <lnxbuild@localhost>2020-09-06 21:44:27 -0700
committerGerrit - the friendly Code Review server <code-review@localhost>2020-09-06 21:44:26 -0700
commit353b81f1fbec379322908cec16dcb7f6b3167fb6 (patch)
treee891e05affd814f91bc3bfd9a4e8b92e9fc6a62c
parent555c6a048e537bcf7c9b40a93dfbee762503c7d2 (diff)
parenta844e7d2b4f9583aa09e9af5d58ff084831cb509 (diff)
Merge "asoc: add missing null check for pcm pointer of snd_pcm_volume"
-rw-r--r--sound/soc/msm/qdsp6v2/msm-pcm-loopback-v2.c29
-rw-r--r--sound/soc/msm/qdsp6v2/msm-pcm-q6-noirq.c32
-rw-r--r--sound/soc/msm/qdsp6v2/msm-pcm-q6-v2.c30
3 files changed, 79 insertions, 12 deletions
diff --git a/sound/soc/msm/qdsp6v2/msm-pcm-loopback-v2.c b/sound/soc/msm/qdsp6v2/msm-pcm-loopback-v2.c
index 0add46fb979f..24f9740a9511 100644
--- a/sound/soc/msm/qdsp6v2/msm-pcm-loopback-v2.c
+++ b/sound/soc/msm/qdsp6v2/msm-pcm-loopback-v2.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013-2019, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2013-2020, The Linux Foundation. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 and
@@ -545,11 +545,23 @@ 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];
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[0].substream;
mutex_lock(&loopback_session_lock);
if ((!substream) || (!substream->runtime)) {
pr_err("%s substream or runtime not found\n", __func__);
@@ -579,6 +591,19 @@ static int msm_pcm_volume_ctl_get(struct snd_kcontrol *kcontrol,
struct msm_pcm_loopback *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) || (!substream->runtime)) {
pr_err("%s substream or runtime not found\n", __func__);
rc = -ENODEV;
diff --git a/sound/soc/msm/qdsp6v2/msm-pcm-q6-noirq.c b/sound/soc/msm/qdsp6v2/msm-pcm-q6-noirq.c
index 5c78349f8d70..4ef4ae7d72c8 100644
--- a/sound/soc/msm/qdsp6v2/msm-pcm-q6-noirq.c
+++ b/sound/soc/msm/qdsp6v2/msm-pcm-q6-noirq.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2016-2017, 2019 The Linux Foundation. All rights reserved.
+/* Copyright (c) 2016-2017, 2019-2020 The Linux Foundation. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 and
@@ -662,12 +662,22 @@ 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;
@@ -699,13 +709,25 @@ 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[SNDRV_PCM_STREAM_PLAYBACK].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: 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[SNDRV_PCM_STREAM_PLAYBACK].substream;
+
if (!substream) {
pr_err("%s substream not found\n", __func__);
return -ENODEV;
diff --git a/sound/soc/msm/qdsp6v2/msm-pcm-q6-v2.c b/sound/soc/msm/qdsp6v2/msm-pcm-q6-v2.c
index b2154620c8ae..c1ef60bd8cba 100644
--- a/sound/soc/msm/qdsp6v2/msm-pcm-q6-v2.c
+++ b/sound/soc/msm/qdsp6v2/msm-pcm-q6-v2.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012-2019, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2012-2020, The Linux Foundation. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 and
@@ -1389,12 +1389,22 @@ 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;
@@ -1426,14 +1436,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 snd_pcm_substream *substream =
- vol->pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream;
+ struct snd_pcm_substream *substream = NULL;
struct msm_audio *prtd;
int volume = ucontrol->value.integer.value[0];
struct snd_soc_pcm_runtime *soc_prtd = NULL;
struct msm_plat_data *pdata = NULL;
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[SNDRV_PCM_STREAM_PLAYBACK].substream;
if (!substream) {
pr_err("%s: substream not found\n", __func__);
return -ENODEV;