RE: [PATCH v2 4/5] ASoC: sdw_utils: honor empty DisCo port lists when creating DAI links

From: Liao, Bard

Date: Tue Nov 03 2026 - 22:01:35 EST




> -----Original Message-----
> From: Matthew Schwartz <matthew.schwartz@xxxxxxxxx>
> Sent: Wednesday, November 4, 2026 4:06 AM
> To: broonie@xxxxxxxxxx
> Cc: Matthew Schwartz <matthew.schwartz@xxxxxxxxx>; Liam Girdwood
> <lgirdwood@xxxxxxxxx>; Jaroslav Kysela <perex@xxxxxxxx>; Takashi Iwai
> <tiwai@xxxxxxxx>; Vijendar Mukunda <Vijendar.Mukunda@xxxxxxx>;
> Venkata Prasad Potturu <venkataprasad.potturu@xxxxxxx>; Rojewski,
> Cezary <cezary.rojewski@xxxxxxxxx>; Peter Ujfalusi
> <peter.ujfalusi@xxxxxxxxxxxxxxx>; Bard Liao <yung-
> chuan.liao@xxxxxxxxxxxxxxx>; Kai Vehmanen <kai.vehmanen@xxxxxxxxxxxxxxx>;
> Pierre-Louis Bossart <pierre-louis.bossart@xxxxxxxxx>; linux-
> sound@xxxxxxxxxxxxxxx; linux-kernel@xxxxxxxxxxxxxxx
> Subject: [PATCH v2 4/5] ASoC: sdw_utils: honor empty DisCo port lists when
> creating DAI links
>
> The codec_info tables give each DAI a fixed direction, so a TAS2783
> always gets an amp feedback capture link. The ASUS ROG Xbox Ally X20
> BIOS declares mipi-sdw-source-port-list as 0 for both of its TAS2783s,
> so the capture port has no DisCo properties and every open of the
> SmartAmp capture PCM fails in sdw_program_slave_port_params() with
> -EINVAL. The PCM is probed at session start, which logs a burst of
> transport errors on every boot, and the same failure is reported on the
> ASUS ProArt PX13.
>
> Store the effective direction in each endpoint and, for codecs whose
> driver takes its ports from the DisCo port lists, drop a direction when
> the peripheral declares an empty list for it, and skip the endpoint when
> neither direction is left. Other codecs keep the table direction, as
> many of their drivers use fixed port masks. Since endpoints in one group
> can now differ, the machine drivers take the stream name and DAI link ID
> from an endpoint that is part of the stream, and only count and
> initialize those endpoints.
>
> Signed-off-by: Matthew Schwartz <matthew.schwartz@xxxxxxxxx>
> ---
[...]
> int asoc_sdw_parse_sdw_endpoints(struct device *dev,
> struct asoc_sdw_mc_private *ctx,
> struct snd_soc_aux_dev *soc_aux,
> @@ -2493,6 +2520,26 @@ int asoc_sdw_parse_sdw_endpoints(struct
> device *dev,
>
> adr_end = &adr_dev->endpoints[j];
> dai_info = &codec_info->dais[adr_end->num];
> +
> + if (adr_end->num >= codec_info->dai_num) {
> + dev_err(dev,
> + "%d is too many endpoints for
> codec: 0x%x\n",
> + adr_end->num, codec_info-
> >part_id);
> + return -EINVAL;
> + }

This bounds check comes after `codec_info->dais[adr_end->num]`.
Please move it before the array access to validate the index first.