mirror of
https://github.com/team-infusion-developers/android_kernel_samsung_msm8976.git
synced 2024-10-31 18:09:19 +00:00
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. Change-Id: Iccbcfe82f716fc0ffe0a26b1779dcaa1c3cb805b Signed-off-by: Rohit kumar <rohitkr@codeaurora.org> Signed-off-by: Vatsal Bucha <vbucha@codeaurora.org>
This commit is contained in:
parent
9be69e398a
commit
a72aa003e4
1 changed files with 50 additions and 2 deletions
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2012-2017, The Linux Foundation. All rights reserved.
|
* Copyright (c) 2012-2017, 2019 The Linux Foundation. All rights reserved.
|
||||||
* Author: Brian Swetland <swetland@google.com>
|
* Author: Brian Swetland <swetland@google.com>
|
||||||
*
|
*
|
||||||
* This software is licensed under the terms of the GNU General Public
|
* This software is licensed under the terms of the GNU General Public
|
||||||
|
@ -3013,6 +3013,12 @@ int q6asm_open_shared_io(struct audio_client *ac,
|
||||||
if (!ac || !config)
|
if (!ac || !config)
|
||||||
return -EINVAL;
|
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;
|
bufsz = config->bufsz;
|
||||||
bufcnt = config->bufcnt;
|
bufcnt = config->bufcnt;
|
||||||
num_watermarks = 0;
|
num_watermarks = 0;
|
||||||
|
@ -3407,6 +3413,13 @@ int q6asm_set_encdec_chan_map(struct audio_client *ac,
|
||||||
struct asm_dec_out_chan_map_param chan_map;
|
struct asm_dec_out_chan_map_param chan_map;
|
||||||
u8 *channel_mapping;
|
u8 *channel_mapping;
|
||||||
int rc = 0;
|
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",
|
pr_debug("%s: Session %d, num_channels = %d\n",
|
||||||
__func__, ac->session, num_channels);
|
__func__, ac->session, num_channels);
|
||||||
q6asm_add_hdr(ac, &chan_map.hdr, sizeof(chan_map), TRUE);
|
q6asm_add_hdr(ac, &chan_map.hdr, sizeof(chan_map), TRUE);
|
||||||
|
@ -3475,6 +3488,12 @@ int q6asm_enc_cfg_blk_pcm_v3(struct audio_client *ac,
|
||||||
u32 frames_per_buf = 0;
|
u32 frames_per_buf = 0;
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
|
if (channels > PCM_FORMAT_MAX_NUM_CHANNEL) {
|
||||||
|
pr_err("%s: Invalid channel count %d\n", __func__, channels);
|
||||||
|
rc = -EINVAL;
|
||||||
|
goto fail_cmd;
|
||||||
|
}
|
||||||
|
|
||||||
if (!use_default_chmap && (channel_map == NULL)) {
|
if (!use_default_chmap && (channel_map == NULL)) {
|
||||||
pr_err("%s: No valid chan map and can't use default\n",
|
pr_err("%s: No valid chan map and can't use default\n",
|
||||||
__func__);
|
__func__);
|
||||||
|
@ -3558,6 +3577,11 @@ int q6asm_enc_cfg_blk_pcm_v2(struct audio_client *ac,
|
||||||
|
|
||||||
int rc = 0;
|
int rc = 0;
|
||||||
|
|
||||||
|
if (channels > PCM_FORMAT_MAX_NUM_CHANNEL) {
|
||||||
|
pr_err("%s: Invalid channel count %d\n", __func__, channels);
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
if (!use_default_chmap && (channel_map == NULL)) {
|
if (!use_default_chmap && (channel_map == NULL)) {
|
||||||
pr_err("%s: No valid chan map and can't use default\n",
|
pr_err("%s: No valid chan map and can't use default\n",
|
||||||
__func__);
|
__func__);
|
||||||
|
@ -3678,9 +3702,13 @@ int q6asm_enc_cfg_blk_pcm_native(struct audio_client *ac,
|
||||||
struct asm_multi_channel_pcm_enc_cfg_v2 enc_cfg;
|
struct asm_multi_channel_pcm_enc_cfg_v2 enc_cfg;
|
||||||
u8 *channel_mapping;
|
u8 *channel_mapping;
|
||||||
u32 frames_per_buf = 0;
|
u32 frames_per_buf = 0;
|
||||||
|
|
||||||
int rc = 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__,
|
pr_debug("%s: Session %d, rate = %d, channels = %d\n", __func__,
|
||||||
ac->session, rate, channels);
|
ac->session, rate, channels);
|
||||||
|
|
||||||
|
@ -4117,6 +4145,11 @@ static int __q6asm_media_format_block_pcm(struct audio_client *ac,
|
||||||
u8 *channel_mapping;
|
u8 *channel_mapping;
|
||||||
int rc = 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]ch[%d]\n", __func__, ac->session, rate,
|
pr_debug("%s: session[%d]rate[%d]ch[%d]\n", __func__, ac->session, rate,
|
||||||
channels);
|
channels);
|
||||||
|
|
||||||
|
@ -4190,6 +4223,11 @@ static int __q6asm_media_format_block_pcm_v3(struct audio_client *ac,
|
||||||
u8 *channel_mapping;
|
u8 *channel_mapping;
|
||||||
int rc;
|
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__,
|
pr_debug("%s: session[%d]rate[%d]ch[%d]bps[%d]wordsize[%d]\n", __func__,
|
||||||
ac->session, rate, channels,
|
ac->session, rate, channels,
|
||||||
bits_per_sample, sample_word_size);
|
bits_per_sample, sample_word_size);
|
||||||
|
@ -4335,6 +4373,11 @@ static int __q6asm_media_format_block_multi_ch_pcm(struct audio_client *ac,
|
||||||
u8 *channel_mapping;
|
u8 *channel_mapping;
|
||||||
int rc = 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]ch[%d]\n", __func__, ac->session, rate,
|
pr_debug("%s: session[%d]rate[%d]ch[%d]\n", __func__, ac->session, rate,
|
||||||
channels);
|
channels);
|
||||||
|
|
||||||
|
@ -4397,6 +4440,11 @@ static int __q6asm_media_format_block_multi_ch_pcm_v3(struct audio_client *ac,
|
||||||
u8 *channel_mapping;
|
u8 *channel_mapping;
|
||||||
int rc;
|
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__,
|
pr_debug("%s: session[%d]rate[%d]ch[%d]bps[%d]wordsize[%d]\n", __func__,
|
||||||
ac->session, rate, channels,
|
ac->session, rate, channels,
|
||||||
bits_per_sample, sample_word_size);
|
bits_per_sample, sample_word_size);
|
||||||
|
|
Loading…
Reference in a new issue