]> git.baikalelectronics.ru Git - kernel.git/commit
Merge series "ASoC: topology: fix use-after-free when removing components" from Pierr...
authorMark Brown <broonie@kernel.org>
Mon, 15 Jun 2020 14:18:35 +0000 (15:18 +0100)
committerMark Brown <broonie@kernel.org>
Mon, 15 Jun 2020 14:18:35 +0000 (15:18 +0100)
commit78e4f9a7799bbeb5112dc44450c7ded43fd6b447
treef3199e8790bb0e114cd2863b50e783691767270e
parent5368eaa53722eaf2ce6c3332acee123e4ee85b57
parent73d50c3588d47db501888971e4725fe5c7cc3b06
Merge series "ASoC: topology: fix use-after-free when removing components" from Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>:

This patchset fixes a memory allocation issue and removes a 100%
reproducible use-after-free report thrown by KASAN in automated module
removal tests across multiple platforms.

All the credit goes to Bard Liao for root-causing the issue. DAIs may
be registered at the same time as a component, or when the topology is
loaded. This two-step registration causes the memory for
topology-based DAIs to allocated last, and conversely to be released
first by devres, before the component is released and the DAIs removed
from the component DAI list with snd_soc_unregister_dais().

When we remove a component, by the time we walk through its dai list
to unregister all dais, the dais allocated by the topology have been
freed already by devres and the list is corrupted with pointers that
are no longer valid.

The suggestion is to add an explicit devm_ based registration for
topology-based dais, so that each dai is cleanly removed from the
component dai list in the release operation before devres releases the
allocated memory.

Pierre-Louis Bossart (2):
  ASoC: soc-devres: add devm_snd_soc_register_dai()
  ASoC: soc-topology: use devm_snd_soc_register_dai()

 include/sound/soc.h      |  4 ++++
 sound/soc/soc-devres.c   | 37 +++++++++++++++++++++++++++++++++++++
 sound/soc/soc-topology.c |  3 +--
 3 files changed, 42 insertions(+), 2 deletions(-)

--
2.20.1