Merge "dsp: asm: Add check for num_channels before calling q6asm_map_channels"

This commit is contained in:
Linux Build Service Account 2019-03-14 15:24:20 -07:00 • committed by Gerrit - the friendly Code Review server
commit 66547d7c3f
4 changed files with 120 additions and 1 deletions

View file

@ -4719,6 +4719,11 @@ static int msm_compr_channel_mixer_cfg_ctl_put(struct snd_kcontrol *kcontrol,
chmixer_pspd->in_ch_map[i] =
pdata->ch_map[fe_id]->channel_map[i];
} else {
if (chmixer_pspd->input_channel > PCM_FORMAT_MAX_NUM_CHANNEL_V8) {
pr_err("%s: Invalid channel count %d\n",
__func__, chmixer_pspd->input_channel);
return -EINVAL;
}
q6asm_map_channels(asm_ch_map,
chmixer_pspd->input_channel, false);
for (i = 0; i < PCM_FORMAT_MAX_NUM_CHANNEL_V8; i++)
@ -4733,6 +4738,11 @@ static int msm_compr_channel_mixer_cfg_ctl_put(struct snd_kcontrol *kcontrol,
chmixer_pspd->out_ch_map[i] =
pdata->ch_map[fe_id]->channel_map[i];
} else {
if (chmixer_pspd->output_channel > PCM_FORMAT_MAX_NUM_CHANNEL_V8) {
pr_err("%s: Invalid channel count %d\n",
__func__, chmixer_pspd->output_channel);
return -EINVAL;
}
q6asm_map_channels(asm_ch_map,
chmixer_pspd->output_channel, false);
for (i = 0; i < PCM_FORMAT_MAX_NUM_CHANNEL_V8; i++)

View file

@ -809,6 +809,11 @@ static int msm_pcm_channel_mixer_cfg_ctl_put(struct snd_kcontrol *kcontrol,
if (chmixer_pspd->enable) {
if (session_type == SESSION_TYPE_RX &&
!chmixer_pspd->override_in_ch_map) {
if (chmixer_pspd->input_channel > PCM_FORMAT_MAX_NUM_CHANNEL_V8) {
pr_err("%s: Invalid channel count %d\n",
__func__, chmixer_pspd->input_channel);
return -EINVAL;
}
q6asm_map_channels(asm_ch_map,
chmixer_pspd->input_channel, false);
for (i = 0; i < PCM_FORMAT_MAX_NUM_CHANNEL_V8; i++)
@ -817,6 +822,11 @@ static int msm_pcm_channel_mixer_cfg_ctl_put(struct snd_kcontrol *kcontrol,
reset_override_in_ch_map = true;
} else if (session_type == SESSION_TYPE_TX &&
!chmixer_pspd->override_out_ch_map) {
if (chmixer_pspd->output_channel > PCM_FORMAT_MAX_NUM_CHANNEL_V8) {
pr_err("%s: Invalid channel count %d\n",
__func__, chmixer_pspd->output_channel);
return -EINVAL;
}
q6asm_map_channels(asm_ch_map,
chmixer_pspd->output_channel, false);
for (i = 0; i < PCM_FORMAT_MAX_NUM_CHANNEL_V8; i++)

View file

@ -1939,6 +1939,11 @@ static int msm_pcm_channel_mixer_cfg_ctl_put(struct snd_kcontrol *kcontrol,
chmixer_pspd->in_ch_map[i] =
pdata->ch_map[fe_id]->channel_map[i];
} else {
if (chmixer_pspd->input_channel > PCM_FORMAT_MAX_NUM_CHANNEL_V8) {
pr_err("%s: Invalid channel count %d\n",
__func__, chmixer_pspd->input_channel);
return -EINVAL;
}
q6asm_map_channels(asm_ch_map,
chmixer_pspd->input_channel, false);
for (i = 0; i < PCM_FORMAT_MAX_NUM_CHANNEL_V8; i++)
@ -1954,6 +1959,11 @@ static int msm_pcm_channel_mixer_cfg_ctl_put(struct snd_kcontrol *kcontrol,
chmixer_pspd->out_ch_map[i] =
pdata->ch_map[fe_id]->channel_map[i];
} else {
if (chmixer_pspd->output_channel > PCM_FORMAT_MAX_NUM_CHANNEL_V8) {
pr_err("%s: Invalid channel count %d\n",
__func__, chmixer_pspd->output_channel);
return -EINVAL;
}
q6asm_map_channels(asm_ch_map,
chmixer_pspd->output_channel, false);
for (i = 0; i < PCM_FORMAT_MAX_NUM_CHANNEL_V8; i++)

View file

@ -4286,6 +4286,12 @@ int q6asm_open_shared_io(struct audio_client *ac,
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;
@ -4685,6 +4691,11 @@ int q6asm_enc_cfg_blk_custom(struct audio_client *ac,
custom_size = enc_generic->reserved[1];
if (channels > PCM_FORMAT_MAX_NUM_CHANNEL) {
pr_err("%s: Invalid channel count %d\n", __func__, channels);
return -EINVAL;
}
pr_debug("%s: session[%d] size[%d] res[2]=[%d] res[3]=[%d]\n",
__func__, ac->session, custom_size, enc_generic->reserved[2],
enc_generic->reserved[3]);
@ -4903,6 +4914,12 @@ int q6asm_set_encdec_chan_map(struct audio_client *ac,
u8 *channel_mapping;
int rc = 0;
if (num_channels > MAX_CHAN_MAP_CHANNELS) {
pr_err("%s: Invalid channel count %d\n", __func__,
num_channels);
return -EINVAL;
}
pr_debug("%s: Session %d, num_channels = %d\n",
__func__, ac->session, num_channels);
q6asm_add_hdr(ac, &chan_map.hdr, sizeof(chan_map), TRUE);
@ -4985,6 +5002,12 @@ static int q6asm_enc_cfg_blk_pcm_v5(struct audio_client *ac,
goto fail_cmd;
}
if (channels > PCM_FORMAT_MAX_NUM_CHANNEL_V8) {
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);
@ -5087,6 +5110,12 @@ int q6asm_enc_cfg_blk_pcm_v4(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);
@ -5187,6 +5216,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);
@ -5284,6 +5319,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);
@ -5499,9 +5539,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);
@ -6119,6 +6163,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);
@ -6202,6 +6251,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);
@ -6286,6 +6340,11 @@ static int __q6asm_media_format_block_pcm_v4(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);
@ -6373,6 +6432,11 @@ static int __q6asm_media_format_block_pcm_v5(struct audio_client *ac,
u8 *channel_mapping;
int rc;
if (channels > PCM_FORMAT_MAX_NUM_CHANNEL_V8) {
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);
@ -6625,6 +6689,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);
@ -6693,6 +6762,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);
@ -6765,6 +6839,11 @@ static int __q6asm_media_format_block_multi_ch_pcm_v4(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);
@ -6839,6 +6918,11 @@ static int __q6asm_media_format_block_multi_ch_pcm_v5(struct audio_client *ac,
u8 *channel_mapping;
int rc;
if (channels > PCM_FORMAT_MAX_NUM_CHANNEL_V8) {
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);
@ -7031,6 +7115,11 @@ int q6asm_media_format_block_gen_compr(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]bps[%d]\n",
__func__, ac->session, rate,
channels, bits_per_sample);