summaryrefslogtreecommitdiffstats
path: root/sound/soc/intel/skylake/skl-topology.c
diff options
context:
space:
mode:
authorVinod Koul2016-02-03 13:29:44 +0100
committerMark Brown2016-02-04 12:36:14 +0100
commit41556f68d1dd0b6bbf311a220523b034d2a040e7 (patch)
tree4a9a5c0c3ba379e4c755b814ecfbb112d40ab2f9 /sound/soc/intel/skylake/skl-topology.c
parentASoC: Intel: Atom: fix regression on compress DAI (diff)
downloadkernel-qcow2-linux-41556f68d1dd0b6bbf311a220523b034d2a040e7.tar.gz
kernel-qcow2-linux-41556f68d1dd0b6bbf311a220523b034d2a040e7.tar.xz
kernel-qcow2-linux-41556f68d1dd0b6bbf311a220523b034d2a040e7.zip
ASoC: Intel: Skylake: Fix the memory overwrite of tlv buffer
TLV buffer can be smaller than the module data, so update the size of data to be copied before doing the copy. Also TLV header consists of two unsigned ints, this is also taken into account here and size modified to reflect this Suggested-by: Takashi Iwai <tiwai@suse.de> Signed-off-by: Vinod Koul <vinod.koul@intel.com> Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'sound/soc/intel/skylake/skl-topology.c')
-rw-r--r--sound/soc/intel/skylake/skl-topology.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/sound/soc/intel/skylake/skl-topology.c b/sound/soc/intel/skylake/skl-topology.c
index c7816d52ad08..c67e3acb8102 100644
--- a/sound/soc/intel/skylake/skl-topology.c
+++ b/sound/soc/intel/skylake/skl-topology.c
@@ -916,6 +916,13 @@ static int skl_tplg_tlv_control_get(struct snd_kcontrol *kcontrol,
skl_get_module_params(skl->skl_sst, (u32 *)bc->params,
bc->max, bc->param_id, mconfig);
+ /* decrement size for TLV header */
+ size -= 2 * sizeof(u32);
+
+ /* check size as we don't want to send kernel data */
+ if (size > bc->max)
+ size = bc->max;
+
if (bc->params) {
if (copy_to_user(data, &bc->param_id, sizeof(u32)))
return -EFAULT;