]> git.baikalelectronics.ru Git - kernel.git/commit
ASoC: SOF: ipc3-topology: Move and correct size checks in sof_ipc3_control_load_bytes()
authorPeter Ujfalusi <peter.ujfalusi@linux.intel.com>
Fri, 10 Jun 2022 08:47:35 +0000 (11:47 +0300)
committerMark Brown <broonie@kernel.org>
Fri, 10 Jun 2022 12:31:36 +0000 (13:31 +0100)
commitb7c2f79ee3a90c598c1ab76b53b87bb67b3394ba
tree2b1a8d70ea2758aabcbb047ad50cef6de7f659ad
parent0c280e1b20be2e5676eeeb0fc5a9f213d49f399b
ASoC: SOF: ipc3-topology: Move and correct size checks in sof_ipc3_control_load_bytes()

Move the size checks prior to allocating memory as these checks do not need
the data to be allocated and in case of an error we would not need to free
the allocation.

The max size must not be less than the size of
struct sof_ipc_ctrl_data + struct sof_abi_hdr as the ABI header needs to
be present under all circumstances.
The check was incorrectly used or between the two size checks.

Fixes: 806f4f0b3d81 ("ASoC: SOF: topology: Make control parsing IPC agnostic")
Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Reviewed-by: Bard Liao <yung-chuan.liao@linux.intel.com>
Link: https://lore.kernel.org/r/20220610084735.19397-1-peter.ujfalusi@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/sof/ipc3-topology.c