* [PATCH] ASoC: codecs: rt712-sdca-dmic: fix uninitialized stream_config->type
@ 2026-09-14 10:47 Jiangshan Yi
2026-09-14 17:55 ` Pierre-Louis Bossart
2026-09-14 19:04 ` Mark Brown
0 siblings, 2 replies; 3+ messages in thread
From: Jiangshan Yi @ 2026-09-14 10:47 UTC (permalink / raw)
To: oder_chiou, lgirdwood, broonie, perex, tiwai
Cc: shumingf, linux-sound, linux-kernel, 13667453960, Jiangshan Yi, stable
stream_config is not initialized before being passed to
sdw_stream_add_slave(). The type field may contain garbage and is
later copied to stream->type by sdw_config_stream().
Zero-initialize stream_config so type defaults to SDW_STREAM_PCM.
While at it, use snd_sdw_params_to_config() helper instead of
open-coding the same logic.
Fixes: 63a511284c9e ("ASoC: rt712-sdca: Add RT712 SDCA driver for Mic topology")
Cc: stable@vger.kernel.org
Signed-off-by: Jiangshan Yi <yijiangshan@kylinos.cn>
---
sound/soc/codecs/rt712-sdca-dmic.c | 14 +++++---------
1 file changed, 5 insertions(+), 9 deletions(-)
diff --git a/sound/soc/codecs/rt712-sdca-dmic.c b/sound/soc/codecs/rt712-sdca-dmic.c
index 8860d81134e7..a9f3aa4e143a 100644
--- a/sound/soc/codecs/rt712-sdca-dmic.c
+++ b/sound/soc/codecs/rt712-sdca-dmic.c
@@ -13,6 +13,7 @@
#include <sound/core.h>
#include <sound/pcm.h>
#include <sound/pcm_params.h>
+#include <sound/sdw.h>
#include <sound/tlv.h>
#include "rt712-sdca.h"
#include "rt712-sdca-dmic.h"
@@ -632,10 +633,10 @@ static int rt712_sdca_dmic_hw_params(struct snd_pcm_substream *substream,
{
struct snd_soc_component *component = dai->component;
struct rt712_sdca_dmic_priv *rt712 = snd_soc_component_get_drvdata(component);
- struct sdw_stream_config stream_config;
+ struct sdw_stream_config stream_config = {0};
struct sdw_port_config port_config;
struct sdw_stream_runtime *sdw_stream;
- int retval, num_channels;
+ int retval;
unsigned int sampling_rate;
dev_dbg(dai->dev, "%s %s", __func__, dai->name);
@@ -647,13 +648,8 @@ static int rt712_sdca_dmic_hw_params(struct snd_pcm_substream *substream,
if (!rt712->slave)
return -EINVAL;
- stream_config.frame_rate = params_rate(params);
- stream_config.ch_count = params_channels(params);
- stream_config.bps = snd_pcm_format_width(params_format(params));
- stream_config.direction = SDW_DATA_DIR_TX;
-
- num_channels = params_channels(params);
- port_config.ch_mask = GENMASK(num_channels - 1, 0);
+ /* SoundWire specific configuration */
+ snd_sdw_params_to_config(substream, params, &stream_config, &port_config);
port_config.num = 2;
retval = sdw_stream_add_slave(rt712->slave, &stream_config,
--
2.25.1
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] ASoC: codecs: rt712-sdca-dmic: fix uninitialized stream_config->type
2026-09-14 10:47 [PATCH] ASoC: codecs: rt712-sdca-dmic: fix uninitialized stream_config->type Jiangshan Yi
@ 2026-09-14 17:55 ` Pierre-Louis Bossart
2026-09-14 19:04 ` Mark Brown
1 sibling, 0 replies; 3+ messages in thread
From: Pierre-Louis Bossart @ 2026-09-14 17:55 UTC (permalink / raw)
To: Jiangshan Yi, oder_chiou, lgirdwood, broonie, perex, tiwai
Cc: shumingf, linux-sound, linux-kernel, 13667453960, stable
On 9/14/26 12:47, Jiangshan Yi wrote:
> stream_config is not initialized before being passed to
> sdw_stream_add_slave(). The type field may contain garbage and is
> later copied to stream->type by sdw_config_stream().
>
> Zero-initialize stream_config so type defaults to SDW_STREAM_PCM.
>
> While at it, use snd_sdw_params_to_config() helper instead of
> open-coding the same logic.
>
> Fixes: 63a511284c9e ("ASoC: rt712-sdca: Add RT712 SDCA driver for Mic topology")
> Cc: stable@vger.kernel.org
> Signed-off-by: Jiangshan Yi <yijiangshan@kylinos.cn>
> ---
> sound/soc/codecs/rt712-sdca-dmic.c | 14 +++++---------
> 1 file changed, 5 insertions(+), 9 deletions(-)
This change looks correct, and there are quite a few other codecs in the
same directory where the same change could be applied. Just look for
"struct sdw_stream_config stream_config;"
For this patch here's my
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.dev>
>
> diff --git a/sound/soc/codecs/rt712-sdca-dmic.c b/sound/soc/codecs/rt712-sdca-dmic.c
> index 8860d81134e7..a9f3aa4e143a 100644
> --- a/sound/soc/codecs/rt712-sdca-dmic.c
> +++ b/sound/soc/codecs/rt712-sdca-dmic.c
> @@ -13,6 +13,7 @@
> #include <sound/core.h>
> #include <sound/pcm.h>
> #include <sound/pcm_params.h>
> +#include <sound/sdw.h>
> #include <sound/tlv.h>
> #include "rt712-sdca.h"
> #include "rt712-sdca-dmic.h"
> @@ -632,10 +633,10 @@ static int rt712_sdca_dmic_hw_params(struct snd_pcm_substream *substream,
> {
> struct snd_soc_component *component = dai->component;
> struct rt712_sdca_dmic_priv *rt712 = snd_soc_component_get_drvdata(component);
> - struct sdw_stream_config stream_config;
> + struct sdw_stream_config stream_config = {0};
> struct sdw_port_config port_config;
> struct sdw_stream_runtime *sdw_stream;
> - int retval, num_channels;
> + int retval;
> unsigned int sampling_rate;
>
> dev_dbg(dai->dev, "%s %s", __func__, dai->name);
> @@ -647,13 +648,8 @@ static int rt712_sdca_dmic_hw_params(struct snd_pcm_substream *substream,
> if (!rt712->slave)
> return -EINVAL;
>
> - stream_config.frame_rate = params_rate(params);
> - stream_config.ch_count = params_channels(params);
> - stream_config.bps = snd_pcm_format_width(params_format(params));
> - stream_config.direction = SDW_DATA_DIR_TX;
> -
> - num_channels = params_channels(params);
> - port_config.ch_mask = GENMASK(num_channels - 1, 0);
> + /* SoundWire specific configuration */
> + snd_sdw_params_to_config(substream, params, &stream_config, &port_config);
> port_config.num = 2;
>
> retval = sdw_stream_add_slave(rt712->slave, &stream_config,
> --
> 2.25.1
>
>
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] ASoC: codecs: rt712-sdca-dmic: fix uninitialized stream_config->type
2026-09-14 10:47 [PATCH] ASoC: codecs: rt712-sdca-dmic: fix uninitialized stream_config->type Jiangshan Yi
2026-09-14 17:55 ` Pierre-Louis Bossart
@ 2026-09-14 19:04 ` Mark Brown
1 sibling, 0 replies; 3+ messages in thread
From: Mark Brown @ 2026-09-14 19:04 UTC (permalink / raw)
To: oder_chiou, lgirdwood, perex, tiwai, Jiangshan Yi
Cc: shumingf, linux-sound, linux-kernel, 13667453960, stable
On Mon, 14 Sep 2026 18:47:12 +0800, Jiangshan Yi wrote:
> ASoC: codecs: rt712-sdca-dmic: fix uninitialized stream_config->type
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-7.3
Thanks!
[1/1] ASoC: codecs: rt712-sdca-dmic: fix uninitialized stream_config->type
https://git.kernel.org/broonie/sound/c/1e76ec00f75d
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
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-09-14 22:53 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-14 10:47 [PATCH] ASoC: codecs: rt712-sdca-dmic: fix uninitialized stream_config->type Jiangshan Yi
2026-09-14 17:55 ` Pierre-Louis Bossart
2026-09-14 19:04 ` Mark Brown
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®