aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRohit kumar <rohitkr@codeaurora.org>2019-02-04 11:22:49 +0530
committerKelly Rossmoyer <krossmo@google.com>2019-05-09 23:23:28 +0000
commit2a53f55b72ad2f46fefcd09513e5c26163aa94eb (patch)
treea581d94487f6515109840b8a50d7bec3ef353c8c
parentb9e963d973d0a507ed88ac8d3199ac7b89e851fb (diff)
dsp: asm: Add check for num_channels before calling q6asm_map_channels
Channel_mapping array size varies for different commands. Add check for num_channels before calling q6asm_map_channels. Bug: 129851238 Change-Id: Iccbcfe82f716fc0ffe0a26b1779dcaa1c3cb805b Signed-off-by: Rohit kumar <rohitkr@codeaurora.org>
-rw-r--r--sound/soc/msm/qdsp6v2/q6asm.c52
1 files changed, 50 insertions, 2 deletions
diff --git a/sound/soc/msm/qdsp6v2/q6asm.c b/sound/soc/msm/qdsp6v2/q6asm.c
index b3614532d4e..d77b5c8fbe8 100644
--- a/sound/soc/msm/qdsp6v2/q6asm.c
+++ b/sound/soc/msm/qdsp6v2/q6asm.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2012-2016, 2018 The Linux Foundation. All rights reserved.
+ * Copyright (c) 2012-2016, 2018-2019 The Linux Foundation. All rights reserved.
* Author: Brian Swetland <swetland@google.com>
*
* This software is licensed under the terms of the GNU General Public
@@ -3215,6 +3215,12 @@ int q6asm_open_shared_io(struct audio_client *ac,
if (!ac || !config)
return -EINVAL;
+ if (config->channels > PCM_FORMAT_MAX_NUM_CHANNEL) {
+ pr_err("%s: Invalid channel count %d\n", __func__,
+ config->channels);
+ return -EINVAL;
+ }
+
bufsz = config->bufsz;
bufcnt = config->bufcnt;
num_watermarks = 0;
@@ -3679,6 +3685,13 @@ int q6asm_set_encdec_chan_map(struct audio_client *ac,
int rc = 0;
pr_debug("%s: Session %d, num_channels = %d\n",
__func__, ac->session, num_channels);
+
+ if (num_channels > MAX_CHAN_MAP_CHANNELS) {
+ pr_err("%s: Invalid channel count %d\n", __func__,
+ num_channels);
+ return -EINVAL;
+ }
+
q6asm_add_hdr(ac, &chan_map.hdr, sizeof(chan_map), TRUE);
atomic_set(&ac->cmd_state, -1);
chan_map.hdr.opcode = ASM_STREAM_CMD_SET_ENCDEC_PARAM;
@@ -3754,6 +3767,12 @@ int q6asm_enc_cfg_blk_pcm_v3(struct audio_client *ac,
goto fail_cmd;
}
+ if (channels > PCM_FORMAT_MAX_NUM_CHANNEL) {
+ pr_err("%s: Invalid channel count %d\n", __func__, channels);
+ rc = -EINVAL;
+ goto fail_cmd;
+ }
+
pr_debug("%s: session[%d]rate[%d]ch[%d]bps[%d]wordsize[%d]\n", __func__,
ac->session, rate, channels,
bits_per_sample, sample_word_size);
@@ -3836,6 +3855,11 @@ int q6asm_enc_cfg_blk_pcm_v2(struct audio_client *ac,
return -EINVAL;
}
+ if (channels > PCM_FORMAT_MAX_NUM_CHANNEL) {
+ pr_err("%s: Invalid channel count %d\n", __func__, channels);
+ return -EINVAL;
+ }
+
pr_debug("%s: Session %d, rate = %d, channels = %d\n", __func__,
ac->session, rate, channels);
@@ -3954,9 +3978,13 @@ int q6asm_enc_cfg_blk_pcm_native(struct audio_client *ac,
struct asm_multi_channel_pcm_enc_cfg_v2 enc_cfg;
u8 *channel_mapping;
u32 frames_per_buf = 0;
-
int rc = 0;
+ if (channels > PCM_FORMAT_MAX_NUM_CHANNEL) {
+ pr_err("%s: Invalid channel count %d\n", __func__, channels);
+ return -EINVAL;
+ }
+
pr_debug("%s: Session %d, rate = %d, channels = %d\n", __func__,
ac->session, rate, channels);
@@ -4429,6 +4457,11 @@ static int __q6asm_media_format_block_pcm(struct audio_client *ac,
u8 *channel_mapping;
int rc = 0;
+ if (channels > PCM_FORMAT_MAX_NUM_CHANNEL) {
+ pr_err("%s: Invalid channel count %d\n", __func__, channels);
+ return -EINVAL;
+ }
+
pr_debug("%s: session[%d]rate[%d]ch[%d]\n", __func__, ac->session, rate,
channels);
@@ -4507,6 +4540,11 @@ static int __q6asm_media_format_block_pcm_v3(struct audio_client *ac,
u8 *channel_mapping;
int rc;
+ if (channels > PCM_FORMAT_MAX_NUM_CHANNEL) {
+ pr_err("%s: Invalid channel count %d\n", __func__, channels);
+ return -EINVAL;
+ }
+
pr_debug("%s: session[%d]rate[%d]ch[%d]bps[%d]wordsize[%d]\n", __func__,
ac->session, rate, channels,
bits_per_sample, sample_word_size);
@@ -4652,6 +4690,11 @@ static int __q6asm_media_format_block_multi_ch_pcm(struct audio_client *ac,
u8 *channel_mapping;
int rc = 0;
+ if (channels > PCM_FORMAT_MAX_NUM_CHANNEL) {
+ pr_err("%s: Invalid channel count %d\n", __func__, channels);
+ return -EINVAL;
+ }
+
pr_debug("%s: session[%d]rate[%d]ch[%d]\n", __func__, ac->session, rate,
channels);
@@ -4719,6 +4762,11 @@ static int __q6asm_media_format_block_multi_ch_pcm_v3(struct audio_client *ac,
u8 *channel_mapping;
int rc;
+ if (channels > PCM_FORMAT_MAX_NUM_CHANNEL) {
+ pr_err("%s: Invalid channel count %d\n", __func__, channels);
+ return -EINVAL;
+ }
+
pr_debug("%s: session[%d]rate[%d]ch[%d]bps[%d]wordsize[%d]\n", __func__,
ac->session, rate, channels,
bits_per_sample, sample_word_size);