stable.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sasha Levin <sashal@kernel.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: Yassine Oudjana <y.oudjana@protonmail.com>,
	Mark Brown <broonie@kernel.org>, Sasha Levin <sashal@kernel.org>,
	srinivas.kandagatla@linaro.org, bgoswami@quicinc.com,
	lgirdwood@gmail.com, perex@perex.cz, tiwai@suse.com,
	alsa-devel@alsa-project.org
Subject: [PATCH AUTOSEL 5.18 12/41] ASoC: wcd9335: Remove RX channel from old list before adding it to a new one
Date: Thu, 14 Jul 2022 00:21:52 -0400	[thread overview]
Message-ID: <20220714042221.281187-12-sashal@kernel.org> (raw)
In-Reply-To: <20220714042221.281187-1-sashal@kernel.org>

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

[ Upstream commit be6dd72edb216f20fc80e426ece9fe9b8aabf033 ]

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>
Link: https://lore.kernel.org/r/20220606152226.149164-1-y.oudjana@protonmail.com
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 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 1e60db4056ad..12be043ee9a3 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.35.1


  parent reply	other threads:[~2022-07-14  4:24 UTC|newest]

Thread overview: 44+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-14  4:21 [PATCH AUTOSEL 5.18 01/41] ASoC: ops: Fix off by one in range control validation Sasha Levin
2022-07-14  4:21 ` [PATCH AUTOSEL 5.18 02/41] pinctrl: aspeed: Fix potential NULL dereference in aspeed_pinmux_set_mux() Sasha Levin
2022-07-14  4:21 ` [PATCH AUTOSEL 5.18 03/41] ASoC: Realtek/Maxim SoundWire codecs: disable pm_runtime on remove Sasha Levin
2022-07-14  4:21 ` [PATCH AUTOSEL 5.18 04/41] ASoC: rt711-sdca-sdw: fix calibrate mutex initialization Sasha Levin
2022-07-14  4:21 ` [PATCH AUTOSEL 5.18 05/41] ASoC: Intel: sof_sdw: handle errors on card registration Sasha Levin
2022-07-14  4:21 ` [PATCH AUTOSEL 5.18 06/41] ASoC: rt711: fix calibrate mutex initialization Sasha Levin
2022-07-14  4:21 ` [PATCH AUTOSEL 5.18 07/41] ASoC: rt7*-sdw: harden jack_detect_handler Sasha Levin
2022-07-14  4:21 ` [PATCH AUTOSEL 5.18 08/41] ASoC: codecs: rt700/rt711/rt711-sdca: initialize workqueues in probe Sasha Levin
2022-07-14  4:21 ` [PATCH AUTOSEL 5.18 09/41] ASoC: SOF: Intel: hda-dsp: Expose hda_dsp_core_power_up() Sasha Levin
2022-07-14  4:21 ` [PATCH AUTOSEL 5.18 10/41] ASoC: SOF: Intel: hda-loader: Make sure that the fw load sequence is followed Sasha Levin
2022-07-14  4:21 ` [PATCH AUTOSEL 5.18 11/41] ASoC: SOF: Intel: hda-loader: Clarify the cl_dsp_init() flow Sasha Levin
2022-07-14  4:21 ` Sasha Levin [this message]
2022-07-14  4:21 ` [PATCH AUTOSEL 5.18 13/41] ASoC: wcd9335: Fix spurious event generation Sasha Levin
2022-07-14  4:21 ` [PATCH AUTOSEL 5.18 14/41] ASoC: wcd938x: Fix event generation for some controls Sasha Levin
2022-07-14  4:21 ` [PATCH AUTOSEL 5.18 15/41] ASoC: Intel: bytcr_wm5102: Fix GPIO related probe-ordering problem Sasha Levin
2022-07-14  4:21 ` [PATCH AUTOSEL 5.18 16/41] ASoC: rockchip: i2s: switch BCLK to GPIO Sasha Levin
2022-07-14  4:21 ` [PATCH AUTOSEL 5.18 17/41] ASoC: wm_adsp: Fix event for preloader Sasha Levin
2022-07-14  4:21 ` [PATCH AUTOSEL 5.18 18/41] ASoC: wm5110: Fix DRE control Sasha Levin
2022-07-14  4:21 ` [PATCH AUTOSEL 5.18 19/41] ASoC: cs35l41: Correct some control names Sasha Levin
2022-07-14  4:22 ` [PATCH AUTOSEL 5.18 20/41] ASoC: rt711-sdca: fix kernel NULL pointer dereference when IO error Sasha Levin
2022-07-14  4:22 ` [PATCH AUTOSEL 5.18 21/41] ASoC: dapm: Initialise kcontrol data for mux/demux controls Sasha Levin
2022-07-14  4:22 ` [PATCH AUTOSEL 5.18 22/41] ASoC: cs35l41: Add ASP TX3/4 source to register patch Sasha Levin
2022-07-14  4:22 ` [PATCH AUTOSEL 5.18 23/41] ASoC: cs47l15: Fix event generation for low power mux control Sasha Levin
2022-07-14  4:22 ` [PATCH AUTOSEL 5.18 24/41] ASoC: madera: Fix event generation for OUT1 demux Sasha Levin
2022-07-14  4:22 ` [PATCH AUTOSEL 5.18 25/41] ASoC: madera: Fix event generation for rate controls Sasha Levin
2022-07-14  4:22 ` [PATCH AUTOSEL 5.18 26/41] irqchip: or1k-pic: Undefine mask_ack for level triggered hardware Sasha Levin
2022-07-14  4:22 ` [PATCH AUTOSEL 5.18 27/41] pinctrl: imx: Add the zero base flag for imx93 Sasha Levin
2022-07-14  4:22 ` [PATCH AUTOSEL 5.18 28/41] x86/xen: Use clear_bss() for Xen PV guests Sasha Levin
2022-07-14  4:22 ` [PATCH AUTOSEL 5.18 29/41] x86: Clear .brk area at early boot Sasha Levin
2022-07-14  4:22 ` [PATCH AUTOSEL 5.18 30/41] soc: ixp4xx/npe: Fix unused match warning Sasha Levin
2022-07-14  4:22 ` [PATCH AUTOSEL 5.18 31/41] ARM: dts: stm32: use the correct clock source for CEC on stm32mp151 Sasha Levin
2022-07-14  4:22 ` [PATCH AUTOSEL 5.18 32/41] Revert "can: xilinx_can: Limit CANFD brp to 2" Sasha Levin
2022-07-14  4:22 ` [PATCH AUTOSEL 5.18 33/41] ALSA: usb-audio: Add quirks for MacroSilicon MS2100/MS2106 devices Sasha Levin
2022-07-14  4:22 ` [PATCH AUTOSEL 5.18 34/41] ALSA: usb-audio: Add quirk for Fiero SC-01 Sasha Levin
2022-07-14  4:22 ` [PATCH AUTOSEL 5.18 35/41] ALSA: usb-audio: Add quirk for Fiero SC-01 (fw v1.0.0) Sasha Levin
2022-07-14  4:22 ` [PATCH AUTOSEL 5.18 36/41] nvme-pci: phison e16 has bogus namespace ids Sasha Levin
2022-07-14  4:22 ` [PATCH AUTOSEL 5.18 37/41] nvme: use struct group for generic command dwords Sasha Levin
2022-07-14  4:22 ` [PATCH AUTOSEL 5.18 38/41] wireguard: selftests: set fake real time in init Sasha Levin
2022-07-14  4:22 ` [PATCH AUTOSEL 5.18 39/41] wireguard: selftests: use virt machine on m68k Sasha Levin
2022-07-14  7:08   ` Geert Uytterhoeven
2022-07-17 23:01     ` Sasha Levin
2022-07-18  1:34       ` Sasha Levin
2022-07-14  4:22 ` [PATCH AUTOSEL 5.18 40/41] wireguard: selftests: always call kernel makefile Sasha Levin
2022-07-14  4:22 ` [PATCH AUTOSEL 5.18 41/41] signal handling: don't use BUG_ON() for debugging Sasha Levin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220714042221.281187-12-sashal@kernel.org \
    --to=sashal@kernel.org \
    --cc=alsa-devel@alsa-project.org \
    --cc=bgoswami@quicinc.com \
    --cc=broonie@kernel.org \
    --cc=lgirdwood@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=perex@perex.cz \
    --cc=srinivas.kandagatla@linaro.org \
    --cc=stable@vger.kernel.org \
    --cc=tiwai@suse.com \
    --cc=y.oudjana@protonmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).