[PATCH v3 0/4] ASoC: qcom: sdw: fix memory leak

Srinivas Kandagatla posted 4 patches 3 months, 2 weeks ago
sound/soc/qcom/sc7280.c   |  67 +-------------------
sound/soc/qcom/sc8280xp.c |  33 +---------
sound/soc/qcom/sdm845.c   |  53 +---------------
sound/soc/qcom/sdw.c      | 128 ++++++++++++++++++++++----------------
sound/soc/qcom/sdw.h      |   7 +--
sound/soc/qcom/sm8250.c   |  33 +---------
sound/soc/qcom/x1e80100.c |  33 +---------
7 files changed, 93 insertions(+), 261 deletions(-)
[PATCH v3 0/4] ASoC: qcom: sdw: fix memory leak
Posted by Srinivas Kandagatla 3 months, 2 weeks ago
For some reason we endedup allocating sdw_stream_runtime for every cpu dai,
this has two issues.
    1. we never set snd_soc_dai_set_stream for non soundwire dai, which
       means there is no way that we can free this, resulting in memory leak
    2. startup and shutdown callbacks can be called without
       hw_params callback called. This combination results in memory leak
    because machine driver sruntime array pointer is only set in hw_params
    callback.
    
All the machine drivers have these memory leaks, so cleanup the mess and
make them use common helpers from sdw.c

This patch series fix the issue, and while we are at it, it also remove
some redundant code from machine drivers.

Thanks,
Srini

Changes since v2:
	- adding missing return statement in qcom_snd_is_sdw_dai(),
	  reported by Steev

Changes since v1:
	- added missing dais for sdm845
	- moved all the machine drivers (sdm845 and sc7280) to use
	  common helpers to avoid memory leaks.

Srinivas Kandagatla (4):
  ASoC: qcom: sdw: fix memory leak for sdw_stream_runtime
  ASoC: qcom: sdw: remove redundant code
  ASoC: qcom: sdm845: make use of common helpers
  ASoC: qcom: sc7280: make use of common helpers

 sound/soc/qcom/sc7280.c   |  67 +-------------------
 sound/soc/qcom/sc8280xp.c |  33 +---------
 sound/soc/qcom/sdm845.c   |  53 +---------------
 sound/soc/qcom/sdw.c      | 128 ++++++++++++++++++++++----------------
 sound/soc/qcom/sdw.h      |   7 +--
 sound/soc/qcom/sm8250.c   |  33 +---------
 sound/soc/qcom/x1e80100.c |  33 +---------
 7 files changed, 93 insertions(+), 261 deletions(-)

-- 
2.51.0
Re: [PATCH v3 0/4] ASoC: qcom: sdw: fix memory leak
Posted by Mark Brown 3 months, 1 week ago
On Wed, 22 Oct 2025 15:33:45 +0100, Srinivas Kandagatla wrote:
> For some reason we endedup allocating sdw_stream_runtime for every cpu dai,
> this has two issues.
>     1. we never set snd_soc_dai_set_stream for non soundwire dai, which
>        means there is no way that we can free this, resulting in memory leak
>     2. startup and shutdown callbacks can be called without
>        hw_params callback called. This combination results in memory leak
>     because machine driver sruntime array pointer is only set in hw_params
>     callback.
> 
> [...]

Applied to

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next

Thanks!

[1/4] ASoC: qcom: sdw: fix memory leak for sdw_stream_runtime
      commit: bcba17279327c6e85dee6a97014dc642e2dc93cc
[2/4] ASoC: qcom: sdw: remove redundant code
      commit: d02460317ed9c95aa2c5f6ff1c70e22e1857d95d
[3/4] ASoC: qcom: sdm845: make use of common helpers
      commit: 5fa671232f703a404caa05c581411ea858c4cf16
[4/4] ASoC: qcom: sc7280: make use of common helpers
      commit: 8fdb030fe283c84fd8d378c97ad0f32d6cdec6ce

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark