mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] ASoC: wcd9335: Remove RX channel from old list before adding it to a new one
@ 2022-06-06 15:22 Yassine Oudjana
  2022-06-13 16:07 ` Mark Brown
  0 siblings, 1 reply; 2+ messages in thread
From: Yassine Oudjana @ 2022-06-06 15:22 UTC (permalink / raw)
  To: Srinivas Kandagatla, Banajit Goswami, Liam Girdwood, Mark Brown,
	Jaroslav Kysela, Takashi Iwai
  Cc: Yassine Oudjana, Yassine Oudjana, alsa-devel, linux-arm-msm,
	linux-kernel

From: Yassine Oudjana <y.oudjana@protonmail.com>

Currently in slim_rx_mux_put, an RX channel gets added to a new list
even if it is already in one. This can mess up links and make either
it, the new list head, or both, get linked to the wrong entries.
This can cause an entry to link to itself which in turn ends up
making list_for_each_entry in other functions loop infinitely.
To avoid issues, always remove the RX channel from any list it's in
before adding it to a new list.

Signed-off-by: Yassine Oudjana <y.oudjana@protonmail.com>
---
 sound/soc/codecs/wcd9335.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/sound/soc/codecs/wcd9335.c b/sound/soc/codecs/wcd9335.c
index 617a36a89dfe..597420679505 100644
--- a/sound/soc/codecs/wcd9335.c
+++ b/sound/soc/codecs/wcd9335.c
@@ -1289,9 +1289,12 @@ static int slim_rx_mux_put(struct snd_kcontrol *kc,
 
 	wcd->rx_port_value[port_id] = ucontrol->value.enumerated.item[0];
 
+	/* Remove channel from any list it's in before adding it to a new one */
+	list_del_init(&wcd->rx_chs[port_id].list);
+
 	switch (wcd->rx_port_value[port_id]) {
 	case 0:
-		list_del_init(&wcd->rx_chs[port_id].list);
+		/* Channel already removed from lists. Nothing to do here */
 		break;
 	case 1:
 		list_add_tail(&wcd->rx_chs[port_id].list,
-- 
2.36.1


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] ASoC: wcd9335: Remove RX channel from old list before adding it to a new one
  2022-06-06 15:22 [PATCH] ASoC: wcd9335: Remove RX channel from old list before adding it to a new one Yassine Oudjana
@ 2022-06-13 16:07 ` Mark Brown
  0 siblings, 0 replies; 2+ messages in thread
From: Mark Brown @ 2022-06-13 16:07 UTC (permalink / raw)
  To: perex, yassine.oudjana, lgirdwood, srinivas.kandagatla, tiwai
  Cc: linux-arm-msm, alsa-devel, y.oudjana, linux-kernel

On Mon, 6 Jun 2022 19:22:26 +0400, Yassine Oudjana wrote:
> From: Yassine Oudjana <y.oudjana@protonmail.com>
> 
> Currently in slim_rx_mux_put, an RX channel gets added to a new list
> even if it is already in one. This can mess up links and make either
> it, the new list head, or both, get linked to the wrong entries.
> This can cause an entry to link to itself which in turn ends up
> making list_for_each_entry in other functions loop infinitely.
> To avoid issues, always remove the RX channel from any list it's in
> before adding it to a new list.
> 
> [...]

Applied to

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

Thanks!

[1/1] ASoC: wcd9335: Remove RX channel from old list before adding it to a new one
      commit: 7263fc6c71c3a88c17a1ce3565b7b6f378d13878

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] 2+ messages in thread

end of thread, other threads:[~2022-06-13 18:59 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-06 15:22 [PATCH] ASoC: wcd9335: Remove RX channel from old list before adding it to a new one Yassine Oudjana
2022-06-13 16:07 ` 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®