From 2eb2e613dfc8b4a9a2dca485c047297989221fbc Mon Sep 17 00:00:00 2001 From: Vatsal Bucha Date: Fri, 1 Jun 2018 12:05:25 +0530 Subject: [PATCH] ASoC: Fix null pointer dereference for prtd pointer Private data pointer may not be initialized before access it in adsp_stream_cmd_put. NULL check for prtd avoids the issue. CRs-Fixed: 2250112 Change-Id: I0a033d7e867b183c329941b57b49232729191f1b Signed-off-by: Vatsal Bucha --- asoc/msm-pcm-q6-v2.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/asoc/msm-pcm-q6-v2.c b/asoc/msm-pcm-q6-v2.c index 1dccecdaed88..5da97952c8f5 100644 --- a/asoc/msm-pcm-q6-v2.c +++ b/asoc/msm-pcm-q6-v2.c @@ -686,6 +686,7 @@ static int msm_pcm_open(struct snd_pcm_substream *substream) if (!prtd->audio_client) { pr_info("%s: Could not allocate memory\n", __func__); kfree(prtd); + prtd = NULL; return -ENOMEM; } @@ -1174,6 +1175,12 @@ static int msm_pcm_adsp_stream_cmd_put(struct snd_kcontrol *kcontrol, } prtd = substream->runtime->private_data; + if (prtd == NULL) { + pr_err("%s prtd is null.\n", __func__); + ret = -EINVAL; + goto done; + } + if (prtd->audio_client == NULL) { pr_err("%s prtd is null.\n", __func__); ret = -EINVAL;