ASoC: simple-card-utils: Propagate errors on too many links
authorThierry Reding <treding@nvidia.com>
Fri, 16 Apr 2021 07:11:46 +0000 (09:11 +0200)
committerMark Brown <broonie@kernel.org>
Fri, 16 Apr 2021 15:54:08 +0000 (16:54 +0100)
commit0f687d826736a5b4eee03170382fe54d413b912a
treeb9381d1f457f60c24daeb8f79121bef22fe53869
parentd97140033948363ffdf5ed71dd2366f717e120e7
ASoC: simple-card-utils: Propagate errors on too many links

The DAI counting code doesn't propagate errors when the number of
maximum links is exceeded, which causes subsequent initialization code
to continue to run and that eventually leads to memory corruption with
the code trying to access memory that is out of bounds.

Fix this by propagating errors when the maximum number of links is
reached, which ensures that the driver fails to load and prevents the
memory corruption.

Fixes: f2138aed231c ("ASoC: simple-card-utils: enable flexible CPU/Codec/Platform")
Signed-off-by: Thierry Reding <treding@nvidia.com>
Link: https://lore.kernel.org/r/20210416071147.2149109-1-thierry.reding@gmail.com
Reviewed-by: Jon Hunter <jonathanh@nvidia.com>
Tested-by: Jon Hunter <jonathanh@nvidia.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/generic/audio-graph-card.c
sound/soc/generic/simple-card.c