]> git.hungrycats.org Git - linux/commit
ASoC: xilinx: formatter_pcm: fix stream_data leak on open error
authorRosen Penev <rosenp@gmail.com>
Tue, 11 Aug 2026 18:51:40 +0000 (11:51 -0700)
committerMark Brown <broonie@kernel.org>
Tue, 11 Aug 2026 22:08:26 +0000 (23:08 +0100)
commitb992511180e126150c6ad3580a6fd568c385f4c6
tree06553e403734f28fc1a9558dc3bacc8355577de8
parent071497d28403848edb1844e18234a8b7786d3b6f
ASoC: xilinx: formatter_pcm: fix stream_data leak on open error

In xlnx_formatter_pcm_open(), stream_data is allocated and
adata->play_stream or adata->capture_stream is assigned early.  If a
later step, such as snd_pcm_hw_constraint_step() or
snd_pcm_hw_constraint_integer(), fails, the function returns the error
immediately.  ALSA does not call the close callback when open fails, so
stream_data is leaked and the stream pointer is left dangling, pointing
to a substream that ALSA frees.  A later interrupt would then call
snd_pcm_period_elapsed() on the freed substream.

Free stream_data and clear the stream pointer on the error paths.

Fixes: 6f6c3c36f091 ("ASoC: xlnx: add pcm formatter platform driver")
Assisted-by: opencode:deepseek-v4-flash-free
Signed-off-by: Rosen Penev <rosenp@gmail.com>
Reviewed-by: Michal Simek <michal.simek@amd.com>
Link: https://patch.msgid.link/20260811185140.27149-1-rosenp@gmail.com
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/xilinx/xlnx_formatter_pcm.c