From d151e980f0f718360133bc3331e601ad97cdcb2c Mon Sep 17 00:00:00 2001 From: Guillaume Denneulin Date: Thu, 6 Oct 2011 16:18:34 +0100 Subject: [PATCH] intel_sst: fix post processing ioctl header and size management The sst driver was wrongly calculating the size of headers for post processing ioctls. Also the get method didnt copy enable status if algorithm Change-Id: I28e9028b9aa09eaf746add0edf0ad52c0db1fad1 Signed-off-by: Guillaume Denneulin [fixed comit log and checkpatch errors in patch -Vinod] Signed-off-by: Vinod Koul --- drivers/staging/intel_sst/intel_sst_app_interface.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/drivers/staging/intel_sst/intel_sst_app_interface.c b/drivers/staging/intel_sst/intel_sst_app_interface.c index 9c22fdd..6109562 100644 --- a/drivers/staging/intel_sst/intel_sst_app_interface.c +++ b/drivers/staging/intel_sst/intel_sst_app_interface.c @@ -835,11 +835,11 @@ int sst_create_algo_ipc(struct snd_ppp_params *algo_params, return -ENOMEM; sst_fill_header(&(*msg)->header, IPC_IA_ALG_PARAMS, 1, algo_params->str_id); - (*msg)->header.part.data = sizeof(u32) + - sizeof(*algo_params) + algo_params->size; + (*msg)->header.part.data = sizeof(u32) + sizeof(*algo_params) - + sizeof(algo_params->params) + algo_params->size; memcpy((*msg)->mailbox_data, &(*msg)->header, sizeof(u32)); - memcpy((*msg)->mailbox_data + sizeof(u32), - algo_params, sizeof(*algo_params)); + memcpy((*msg)->mailbox_data + sizeof(u32), algo_params, + sizeof(*algo_params) - sizeof(algo_params->params)); return 0; } @@ -895,7 +895,8 @@ long intel_sst_ioctl_dsp(unsigned int cmd, unsigned long arg) if (retval) break; algo_params.reserved = 0; - if (copy_from_user(msg->mailbox_data + sizeof(algo_params), + if (copy_from_user(msg->mailbox_data + sizeof(algo_params) - + sizeof(algo_params.params) + sizeof(u32), algo_params.params, algo_params.size)) { kfree(msg); return -EFAULT; @@ -943,7 +944,14 @@ long intel_sst_ioctl_dsp(unsigned int cmd, unsigned long arg) tmp = (char __user *)arg + offsetof( struct snd_ppp_params, size); if (copy_to_user(tmp, &algo_params_copied->size, - sizeof(__u32))) { + sizeof(u32))) { + retval = -EFAULT; + goto free_mem; + } + tmp = (char __user *)arg + offsetof( + struct snd_ppp_params, enable); + if (copy_to_user(tmp, &algo_params_copied->enable, + sizeof(u8))) { retval = -EFAULT; goto free_mem; } -- 2.7.4