ASoC: SOF: control: fix size checks for ext_bytes control .get()
authorPierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Mon, 21 Sep 2020 11:08:10 +0000 (14:08 +0300)
committerMark Brown <broonie@kernel.org>
Mon, 21 Sep 2020 22:14:45 +0000 (23:14 +0100)
commit3331bcd6a2f2dbe9c1fa764df695422c99e2f1fb
treeea69ff65806bb266b142fd6f1aeab0cd745dbccc
parent97ee967e6c56db6eb5ed5951276b9a6db04c6489
ASoC: SOF: control: fix size checks for ext_bytes control .get()

cppcheck complains twice:

sound/soc/sof/control.c:436:2: style: Assignment of function parameter
has no effect outside the function. [uselessAssignmentArg]
 size -= sizeof(const struct snd_ctl_tlv);
 ^

sound/soc/sof/control.c:436:7: style: Variable 'size' is assigned a
value that is never used. [unreadVariable]
 size -= sizeof(const struct snd_ctl_tlv);

Somehow we dropped the checks for the size argument when upstreaming
the code, somewhere between v5 and v6.

Re-add a size check to avoid providing userspace with more data that
it asked for.

Also fix all error codes, we should return -ENOSPC instead of -EINVAL.

Fixes: c3078f5397046 ('ASoC: SOF: Add Sound Open Firmware KControl support')
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Reviewed-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Link: https://lore.kernel.org/r/20200921110814.2910477-2-kai.vehmanen@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/sof/control.c