Merge 8bc8a30bdb on remote branch

Change-Id: I063c744b5f1354362c33b497a9bc619dc6fdd05c
This commit is contained in:
Linux Build Service Account 2019-03-29 08:23:16 -07:00
commit 3d4358fbe6
15 changed files with 2514 additions and 486 deletions

View file

@ -1,4 +1,4 @@
/* Copyright (c) 2012-2018, The Linux Foundation. All rights reserved. /* Copyright (c) 2012-2019, The Linux Foundation. All rights reserved.
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License version 2 and
@ -2296,8 +2296,8 @@ struct diag_dci_client_tbl *dci_lookup_client_entry_pid(int tgid)
pid_struct = find_get_pid(entry->tgid); pid_struct = find_get_pid(entry->tgid);
if (!pid_struct) { if (!pid_struct) {
DIAG_LOG(DIAG_DEBUG_DCI, DIAG_LOG(DIAG_DEBUG_DCI,
"diag: valid pid doesn't exist for pid = %d\n", "diag: Exited pid (%d) doesn't match dci client of pid (%d)\n",
entry->tgid); tgid, entry->tgid);
continue; continue;
} }
task_s = get_pid_task(pid_struct, PIDTYPE_PID); task_s = get_pid_task(pid_struct, PIDTYPE_PID);

View file

@ -139,8 +139,11 @@ static void diag_usb_buf_tbl_remove(struct diag_usb_info *usb_info,
* Remove reference from the table if it is the * Remove reference from the table if it is the
* only instance of the buffer * only instance of the buffer
*/ */
if (atomic_read(&entry->ref_count) == 0) if (atomic_read(&entry->ref_count) == 0) {
list_del(&entry->track); list_del(&entry->track);
kfree(entry);
entry = NULL;
}
break; break;
} }
} }
@ -308,28 +311,31 @@ static void diag_usb_write_done(struct diag_usb_info *ch,
if (!ch || !req) if (!ch || !req)
return; return;
spin_lock_irqsave(&ch->write_lock, flags);
ch->write_cnt++; ch->write_cnt++;
entry = diag_usb_buf_tbl_get(ch, req->context); entry = diag_usb_buf_tbl_get(ch, req->context);
if (!entry) { if (!entry) {
pr_err_ratelimited("diag: In %s, unable to find entry %pK in the table\n", pr_err_ratelimited("diag: In %s, unable to find entry %pK in the table\n",
__func__, req->context); __func__, req->context);
spin_unlock_irqrestore(&ch->write_lock, flags);
return; return;
} }
if (atomic_read(&entry->ref_count) != 0) { if (atomic_read(&entry->ref_count) != 0) {
DIAG_LOG(DIAG_DEBUG_MUX, "partial write_done ref %d\n", DIAG_LOG(DIAG_DEBUG_MUX, "partial write_done ref %d\n",
atomic_read(&entry->ref_count)); atomic_read(&entry->ref_count));
diag_ws_on_copy_complete(DIAG_WS_MUX); diag_ws_on_copy_complete(DIAG_WS_MUX);
spin_unlock_irqrestore(&ch->write_lock, flags);
diagmem_free(driver, req, ch->mempool); diagmem_free(driver, req, ch->mempool);
return; return;
} }
DIAG_LOG(DIAG_DEBUG_MUX, "full write_done, ctxt: %d\n", DIAG_LOG(DIAG_DEBUG_MUX, "full write_done, ctxt: %d\n",
ctxt); ctxt);
spin_lock_irqsave(&ch->write_lock, flags);
list_del(&entry->track); list_del(&entry->track);
ctxt = entry->ctxt; ctxt = entry->ctxt;
buf = entry->buf; buf = entry->buf;
len = entry->len; len = entry->len;
kfree(entry); kfree(entry);
entry = NULL;
diag_ws_on_copy_complete(DIAG_WS_MUX); diag_ws_on_copy_complete(DIAG_WS_MUX);
if (ch->ops && ch->ops->write_done) if (ch->ops && ch->ops->write_done)

View file

@ -583,8 +583,8 @@ static int diag_remove_client_entry(struct file *file)
static int diagchar_close(struct inode *inode, struct file *file) static int diagchar_close(struct inode *inode, struct file *file)
{ {
int ret; int ret;
DIAG_LOG(DIAG_DEBUG_USERSPACE, "diag: process exit %s\n", DIAG_LOG(DIAG_DEBUG_USERSPACE, "diag: %s process exit with pid = %d\n",
current->comm); current->comm, current->tgid);
ret = diag_remove_client_entry(file); ret = diag_remove_client_entry(file);
mutex_lock(&driver->diag_maskclear_mutex); mutex_lock(&driver->diag_maskclear_mutex);
driver->mask_clear = 0; driver->mask_clear = 0;
@ -3124,6 +3124,8 @@ static ssize_t diagchar_read(struct file *file, char __user *buf, size_t count,
int exit_stat = 0; int exit_stat = 0;
int write_len = 0; int write_len = 0;
struct diag_md_session_t *session_info = NULL; struct diag_md_session_t *session_info = NULL;
struct pid *pid_struct = NULL;
struct task_struct *task_s = NULL;
mutex_lock(&driver->diagchar_mutex); mutex_lock(&driver->diagchar_mutex);
for (i = 0; i < driver->num_clients; i++) for (i = 0; i < driver->num_clients; i++)
@ -3331,6 +3333,17 @@ exit:
list_for_each_safe(start, temp, &driver->dci_client_list) { list_for_each_safe(start, temp, &driver->dci_client_list) {
entry = list_entry(start, struct diag_dci_client_tbl, entry = list_entry(start, struct diag_dci_client_tbl,
track); track);
pid_struct = find_get_pid(entry->tgid);
if (!pid_struct)
continue;
task_s = get_pid_task(pid_struct, PIDTYPE_PID);
if (!task_s) {
DIAG_LOG(DIAG_DEBUG_DCI,
"diag: valid task doesn't exist for pid = %d\n",
entry->tgid);
continue;
}
if (task_s == entry->client)
if (entry->client->tgid != current->tgid) if (entry->client->tgid != current->tgid)
continue; continue;
if (!entry->in_service) if (!entry->in_service)

View file

@ -536,14 +536,21 @@ int kgsl_context_init(struct kgsl_device_private *dev_priv,
int ret = 0, id; int ret = 0, id;
struct kgsl_process_private *proc_priv = dev_priv->process_priv; struct kgsl_process_private *proc_priv = dev_priv->process_priv;
/*
* Read and increment the context count under lock to make sure
* no process goes beyond the specified context limit.
*/
spin_lock(&proc_priv->ctxt_count_lock);
if (atomic_read(&proc_priv->ctxt_count) > KGSL_MAX_CONTEXTS_PER_PROC) { if (atomic_read(&proc_priv->ctxt_count) > KGSL_MAX_CONTEXTS_PER_PROC) {
KGSL_DRV_ERR(device, KGSL_DRV_ERR(device,
"Per process context limit reached for pid %u", "Per process context limit reached for pid %u",
dev_priv->process_priv->pid); dev_priv->process_priv->pid);
spin_unlock(&proc_priv->ctxt_count_lock);
return -ENOSPC; return -ENOSPC;
} }
atomic_inc(&proc_priv->ctxt_count); atomic_inc(&proc_priv->ctxt_count);
spin_unlock(&proc_priv->ctxt_count_lock);
id = _kgsl_get_context_id(device); id = _kgsl_get_context_id(device);
if (id == -ENOSPC) { if (id == -ENOSPC) {
@ -929,6 +936,7 @@ static struct kgsl_process_private *kgsl_process_private_new(
spin_lock_init(&private->mem_lock); spin_lock_init(&private->mem_lock);
spin_lock_init(&private->syncsource_lock); spin_lock_init(&private->syncsource_lock);
spin_lock_init(&private->ctxt_count_lock);
idr_init(&private->mem_idr); idr_init(&private->mem_idr);
idr_init(&private->syncsource_idr); idr_init(&private->syncsource_idr);

View file

@ -423,6 +423,7 @@ struct kgsl_context {
* @syncsource_lock: Spinlock to protect the syncsource idr * @syncsource_lock: Spinlock to protect the syncsource idr
* @fd_count: Counter for the number of FDs for this process * @fd_count: Counter for the number of FDs for this process
* @ctxt_count: Count for the number of contexts for this process * @ctxt_count: Count for the number of contexts for this process
* @ctxt_count_lock: Spinlock to protect ctxt_count
*/ */
struct kgsl_process_private { struct kgsl_process_private {
unsigned long priv; unsigned long priv;
@ -444,6 +445,7 @@ struct kgsl_process_private {
spinlock_t syncsource_lock; spinlock_t syncsource_lock;
int fd_count; int fd_count;
atomic_t ctxt_count; atomic_t ctxt_count;
spinlock_t ctxt_count_lock;
}; };
/** /**

View file

@ -1,4 +1,4 @@
/* Copyright (c) 2010-2016, The Linux Foundation. All rights reserved. /* Copyright (c) 2010-2016, 2019 The Linux Foundation. All rights reserved.
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License version 2 and
@ -879,8 +879,7 @@ ssize_t audio_in_write(struct file *file,
__func__, audio->ac->session); __func__, audio->ac->session);
} }
} }
xfer = (count > (audio->pcm_cfg.buffer_size)) ? xfer = (count > size) ? size : count;
(audio->pcm_cfg.buffer_size) : count;
if (copy_from_user(cpy_ptr, buf, xfer)) { if (copy_from_user(cpy_ptr, buf, xfer)) {
rc = -EFAULT; rc = -EFAULT;

View file

@ -1,4 +1,4 @@
/* Copyright (c) 2013-2018, The Linux Foundation. All rights reserved. /* Copyright (c) 2013-2019, The Linux Foundation. All rights reserved.
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License version 2 and
@ -735,6 +735,12 @@ ssize_t ipa_read(struct file *filp, char __user *buf, size_t count,
IPADBG("msg=%pK\n", msg); IPADBG("msg=%pK\n", msg);
locked = 0; locked = 0;
mutex_unlock(&ipa_ctx->msg_lock); mutex_unlock(&ipa_ctx->msg_lock);
if (count < sizeof(struct ipa_msg_meta)) {
kfree(msg);
msg = NULL;
ret = -EFAULT;
break;
}
if (copy_to_user(buf, &msg->meta, if (copy_to_user(buf, &msg->meta,
sizeof(struct ipa_msg_meta))) { sizeof(struct ipa_msg_meta))) {
kfree(msg); kfree(msg);
@ -745,6 +751,7 @@ ssize_t ipa_read(struct file *filp, char __user *buf, size_t count,
buf += sizeof(struct ipa_msg_meta); buf += sizeof(struct ipa_msg_meta);
count -= sizeof(struct ipa_msg_meta); count -= sizeof(struct ipa_msg_meta);
if (msg->buff) { if (msg->buff) {
if (count >= msg->meta.msg_len) {
if (copy_to_user(buf, msg->buff, if (copy_to_user(buf, msg->buff,
msg->meta.msg_len)) { msg->meta.msg_len)) {
kfree(msg); kfree(msg);
@ -752,6 +759,12 @@ ssize_t ipa_read(struct file *filp, char __user *buf, size_t count,
ret = -EFAULT; ret = -EFAULT;
break; break;
} }
} else {
kfree(msg);
msg = NULL;
ret = -EFAULT;
break;
}
buf += msg->meta.msg_len; buf += msg->meta.msg_len;
count -= msg->meta.msg_len; count -= msg->meta.msg_len;
msg->callback(msg->buff, msg->meta.msg_len, msg->callback(msg->buff, msg->meta.msg_len,

View file

@ -1,4 +1,4 @@
/* Copyright (c) 2013-2018, The Linux Foundation. All rights reserved. /* Copyright (c) 2013-2019, The Linux Foundation. All rights reserved.
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License version 2 and
@ -742,6 +742,12 @@ ssize_t ipa3_read(struct file *filp, char __user *buf, size_t count,
if (msg) { if (msg) {
locked = 0; locked = 0;
mutex_unlock(&ipa3_ctx->msg_lock); mutex_unlock(&ipa3_ctx->msg_lock);
if (count < sizeof(struct ipa_msg_meta)) {
kfree(msg);
msg = NULL;
ret = -EFAULT;
break;
}
if (copy_to_user(buf, &msg->meta, if (copy_to_user(buf, &msg->meta,
sizeof(struct ipa_msg_meta))) { sizeof(struct ipa_msg_meta))) {
ret = -EFAULT; ret = -EFAULT;
@ -752,6 +758,7 @@ ssize_t ipa3_read(struct file *filp, char __user *buf, size_t count,
buf += sizeof(struct ipa_msg_meta); buf += sizeof(struct ipa_msg_meta);
count -= sizeof(struct ipa_msg_meta); count -= sizeof(struct ipa_msg_meta);
if (msg->buff) { if (msg->buff) {
if (count >= msg->meta.msg_len) {
if (copy_to_user(buf, msg->buff, if (copy_to_user(buf, msg->buff,
msg->meta.msg_len)) { msg->meta.msg_len)) {
ret = -EFAULT; ret = -EFAULT;
@ -759,6 +766,12 @@ ssize_t ipa3_read(struct file *filp, char __user *buf, size_t count,
msg = NULL; msg = NULL;
break; break;
} }
} else {
ret = -EFAULT;
kfree(msg);
msg = NULL;
break;
}
buf += msg->meta.msg_len; buf += msg->meta.msg_len;
count -= msg->meta.msg_len; count -= msg->meta.msg_len;
msg->callback(msg->buff, msg->meta.msg_len, msg->callback(msg->buff, msg->meta.msg_len,

View file

@ -1,4 +1,4 @@
/* Copyright (c) 2015-2018, The Linux Foundation. All rights reserved. /* Copyright (c) 2015-2019, The Linux Foundation. All rights reserved.
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License version 2 and
@ -1636,6 +1636,56 @@ out:
return ret; return ret;
} }
static int wlfw_send_modem_shutdown_msg(void)
{
int ret;
struct wlfw_shutdown_req_msg_v01 req;
struct wlfw_shutdown_resp_msg_v01 resp;
struct msg_desc req_desc, resp_desc;
if (!penv || !penv->wlfw_clnt)
return -ENODEV;
icnss_pr_dbg("Sending modem shutdown request, state: 0x%lx\n",
penv->state);
memset(&req, 0, sizeof(req));
memset(&resp, 0, sizeof(resp));
req.shutdown_valid = 1;
req.shutdown = 1;
req_desc.max_msg_len = WLFW_SHUTDOWN_REQ_MSG_V01_MAX_MSG_LEN;
req_desc.msg_id = QMI_WLFW_SHUTDOWN_REQ_V01;
req_desc.ei_array = wlfw_shutdown_req_msg_v01_ei;
resp_desc.max_msg_len = WLFW_SHUTDOWN_RESP_MSG_V01_MAX_MSG_LEN;
resp_desc.msg_id = QMI_WLFW_SHUTDOWN_RESP_V01;
resp_desc.ei_array = wlfw_shutdown_resp_msg_v01_ei;
ret = qmi_send_req_wait(penv->wlfw_clnt, &req_desc, &req, sizeof(req),
&resp_desc, &resp, sizeof(resp),
WLFW_TIMEOUT_MS);
if (ret < 0) {
icnss_pr_err("Send modem shutdown req failed, ret: %d\n", ret);
goto out;
}
if (resp.resp.result != QMI_RESULT_SUCCESS_V01) {
icnss_pr_err("QMI modem shutdown request rejected result:%d error:%d\n",
resp.resp.result, resp.resp.error);
ret = -resp.resp.result;
goto out;
}
icnss_pr_dbg("modem shutdown request sent successfully, state: 0x%lx\n",
penv->state);
return 0;
out:
return ret;
}
static int wlfw_athdiag_read_send_sync_msg(struct icnss_priv *priv, static int wlfw_athdiag_read_send_sync_msg(struct icnss_priv *priv,
uint32_t offset, uint32_t mem_type, uint32_t offset, uint32_t mem_type,
uint32_t data_len, uint8_t *data) uint32_t data_len, uint8_t *data)
@ -2534,6 +2584,13 @@ static int icnss_modem_notifier_nb(struct notifier_block *nb,
if (code != SUBSYS_BEFORE_SHUTDOWN) if (code != SUBSYS_BEFORE_SHUTDOWN)
return NOTIFY_OK; return NOTIFY_OK;
if (code == SUBSYS_BEFORE_SHUTDOWN && !notif->crashed) {
ret = wlfw_send_modem_shutdown_msg();
if (ret)
icnss_pr_dbg("Fail to send modem shutdown Indication %d\n",
ret);
}
if (test_bit(ICNSS_PDR_REGISTERED, &priv->state)) { if (test_bit(ICNSS_PDR_REGISTERED, &priv->state)) {
set_bit(ICNSS_FW_DOWN, &priv->state); set_bit(ICNSS_FW_DOWN, &priv->state);
icnss_ignore_qmi_timeout(true); icnss_ignore_qmi_timeout(true);

View file

@ -601,6 +601,12 @@ void apr_cb_func(void *buf, int len, void *priv)
pr_err("APR: Wrong paket size\n"); pr_err("APR: Wrong paket size\n");
return; return;
} }
if (hdr->pkt_size < hdr_size) {
pr_err("APR: Packet size less than header size\n");
return;
}
msg_type = hdr->hdr_field; msg_type = hdr->hdr_field;
msg_type = (msg_type >> 0x08) & 0x0003; msg_type = (msg_type >> 0x08) & 0x0003;
if (msg_type >= APR_MSG_TYPE_MAX && msg_type != APR_BASIC_RSP_RESULT) { if (msg_type >= APR_MSG_TYPE_MAX && msg_type != APR_BASIC_RSP_RESULT) {

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -55,7 +55,7 @@ def interpret_warning(line):
line = line.rstrip('\n') line = line.rstrip('\n')
m = warning_re.match(line) m = warning_re.match(line)
if m and m.group(2) not in allowed_warnings: if m and m.group(2) not in allowed_warnings:
print "error, forbidden warning:", m.group(2) print >> sys.stderr, "error, forbidden warning:", m.group(2)
# If there is a warning, remove any object if it exists. # If there is a warning, remove any object if it exists.
if ofile: if ofile:
@ -80,17 +80,17 @@ def run_gcc():
try: try:
proc = subprocess.Popen(args, stderr=subprocess.PIPE) proc = subprocess.Popen(args, stderr=subprocess.PIPE)
for line in proc.stderr: for line in proc.stderr:
print line, print >> sys.stderr, line,
interpret_warning(line) interpret_warning(line)
result = proc.wait() result = proc.wait()
except OSError as e: except OSError as e:
result = e.errno result = e.errno
if result == errno.ENOENT: if result == errno.ENOENT:
print args[0] + ':',e.strerror print >> sys.stderr, args[0] + ':',e.strerror
print 'Is your PATH set correctly?' print >> sys.stderr, 'Is your PATH set correctly?'
else: else:
print ' '.join(args), str(e) print >> sys.stderr, ' '.join(args), str(e)
return result return result

View file

@ -1,4 +1,4 @@
/* Copyright (c) 2015-2018, The Linux Foundation. All rights reserved. /* Copyright (c) 2015-2019, The Linux Foundation. All rights reserved.
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License version 2 and
@ -40,6 +40,7 @@
#define CF_MIN_3DB_75HZ 0x1 #define CF_MIN_3DB_75HZ 0x1
#define CF_MIN_3DB_150HZ 0x2 #define CF_MIN_3DB_150HZ 0x2
#define DEC_SVA 5
#define MSM_DIG_CDC_VERSION_ENTRY_SIZE 32 #define MSM_DIG_CDC_VERSION_ENTRY_SIZE 32
static unsigned long rx_digital_gain_reg[] = { static unsigned long rx_digital_gain_reg[] = {
@ -213,6 +214,9 @@ static int msm_dig_cdc_put_dec_enum(struct snd_kcontrol *kcontrol,
tx_mux_ctl_reg = tx_mux_ctl_reg =
MSM89XX_CDC_CORE_TX1_MUX_CTL + 32 * (decimator - 1); MSM89XX_CDC_CORE_TX1_MUX_CTL + 32 * (decimator - 1);
if (decimator == DEC_SVA)
tx_mux_ctl_reg = MSM89XX_CDC_CORE_TX5_MUX_CTL;
snd_soc_update_bits(codec, tx_mux_ctl_reg, 0x1, adc_dmic_sel); snd_soc_update_bits(codec, tx_mux_ctl_reg, 0x1, adc_dmic_sel);
ret = snd_soc_dapm_put_enum_double(kcontrol, ucontrol); ret = snd_soc_dapm_put_enum_double(kcontrol, ucontrol);
@ -939,7 +943,7 @@ static int msm_dig_cdc_codec_enable_dec(struct snd_soc_dapm_widget *w,
32 * (decimator - 1); 32 * (decimator - 1);
tx_mux_ctl_reg = MSM89XX_CDC_CORE_TX1_MUX_CTL + tx_mux_ctl_reg = MSM89XX_CDC_CORE_TX1_MUX_CTL +
32 * (decimator - 1); 32 * (decimator - 1);
if (decimator == 5) { if (decimator == DEC_SVA) {
tx_vol_ctl_reg = MSM89XX_CDC_CORE_TX5_VOL_CTL_CFG; tx_vol_ctl_reg = MSM89XX_CDC_CORE_TX5_VOL_CTL_CFG;
tx_mux_ctl_reg = MSM89XX_CDC_CORE_TX5_MUX_CTL; tx_mux_ctl_reg = MSM89XX_CDC_CORE_TX5_MUX_CTL;
} }
@ -1250,14 +1254,18 @@ static void sdm660_tx_mute_update_callback(struct work_struct *work)
dig_cdc = tx_mute_dwork->dig_cdc; dig_cdc = tx_mute_dwork->dig_cdc;
codec = dig_cdc->codec; codec = dig_cdc->codec;
for (i = 0; i < (NUM_DECIMATORS - 1); i++) { for (i = 0; i < NUM_DECIMATORS; i++) {
if (dig_cdc->dec_active[i]) if (dig_cdc->dec_active[i])
decimator = i + 1; decimator = i + 1;
if (decimator && decimator < NUM_DECIMATORS) { if (decimator && decimator <= NUM_DECIMATORS) {
/* unmute decimators corresponding to Tx DAI's*/ /* unmute decimators corresponding to Tx DAI's*/
tx_vol_ctl_reg = tx_vol_ctl_reg =
MSM89XX_CDC_CORE_TX1_VOL_CTL_CFG + MSM89XX_CDC_CORE_TX1_VOL_CTL_CFG +
32 * (decimator - 1); 32 * (decimator - 1);
if (decimator == DEC_SVA)
tx_vol_ctl_reg =
MSM89XX_CDC_CORE_TX5_VOL_CTL_CFG;
snd_soc_update_bits(codec, tx_vol_ctl_reg, snd_soc_update_bits(codec, tx_vol_ctl_reg,
0x01, 0x00); 0x01, 0x00);
} }

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2012-2018, The Linux Foundation. All rights reserved. * Copyright (c) 2012-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
@ -3973,6 +3973,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;
@ -4432,6 +4438,13 @@ int q6asm_set_encdec_chan_map(struct audio_client *ac,
int rc = 0; int rc = 0;
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);
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); q6asm_add_hdr(ac, &chan_map.hdr, sizeof(chan_map), TRUE);
atomic_set(&ac->cmd_state, -1); atomic_set(&ac->cmd_state, -1);
chan_map.hdr.opcode = ASM_STREAM_CMD_SET_ENCDEC_PARAM; chan_map.hdr.opcode = ASM_STREAM_CMD_SET_ENCDEC_PARAM;
@ -4510,6 +4523,12 @@ static int q6asm_enc_cfg_blk_pcm_v5(struct audio_client *ac,
goto fail_cmd; goto fail_cmd;
} }
if (channels > PCM_FORMAT_MAX_NUM_CHANNEL_V2) {
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__, 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);
@ -4612,6 +4631,12 @@ int q6asm_enc_cfg_blk_pcm_v4(struct audio_client *ac,
goto fail_cmd; 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__, 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);
@ -4711,6 +4736,12 @@ int q6asm_enc_cfg_blk_pcm_v3(struct audio_client *ac,
goto fail_cmd; 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__, 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);
@ -4793,6 +4824,11 @@ int q6asm_enc_cfg_blk_pcm_v2(struct audio_client *ac,
return -EINVAL; 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__, pr_debug("%s: Session %d, rate = %d, channels = %d\n", __func__,
ac->session, rate, channels); ac->session, rate, channels);
@ -4985,9 +5021,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);
@ -5535,6 +5575,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);
@ -5617,6 +5662,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);
@ -5700,6 +5750,11 @@ static int __q6asm_media_format_block_pcm_v4(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);
@ -5888,6 +5943,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);
@ -5955,6 +6015,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);
@ -6026,6 +6091,11 @@ static int __q6asm_media_format_block_multi_ch_pcm_v4(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);
@ -6099,6 +6169,12 @@ static int __q6asm_media_format_block_multi_ch_pcm_v5(struct audio_client *ac,
u8 *channel_mapping; u8 *channel_mapping;
int rc; int rc;
if (channels > PCM_FORMAT_MAX_NUM_CHANNEL_V2) {
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__, 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);
@ -6290,6 +6366,11 @@ int q6asm_media_format_block_gen_compr(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]bps[%d]\n", pr_debug("%s: session[%d]rate[%d]ch[%d]bps[%d]\n",
__func__, ac->session, rate, __func__, ac->session, rate,
channels, bits_per_sample); channels, bits_per_sample);