History

ASoC: wcd9335: Remove RX channel from old list before adding it to a new one

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.

Yassine Oudjana committed 4 years ago

Commit be6dd721 parent 58136d91 file · +4 −1Browse files

Unified · Split

sound/soc/codecs/wcd9335.c+4−1
@@ -1289,9 +1289,12 @@ static int slim_rx_mux_put(struct snd_kcontrol *kc, · 1288 unmodified lines
12891289
12901290 wcd->rx_port_value[port_id] = ucontrol->value.enumerated.item[0];
12911291
1292+ /* Remove channel from any list it's in before adding it to a new one */
1293+ list_del_init(&wcd->rx_chs[port_id].list);
1294+
12921295 switch (wcd->rx_port_value[port_id]) {
12931296 case 0:
1294− list_del_init(&wcd->rx_chs[port_id].list);
1297+ /* Channel already removed from lists. Nothing to do here */
12951298 break;
12961299 case 1:
12971300 list_add_tail(&wcd->rx_chs[port_id].list,