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
1289 1289
1290 wcd->rx_port_value[port_id] = ucontrol->value.enumerated.item[0];1290 wcd->rx_port_value[port_id] = ucontrol->value.enumerated.item[0];
1291 1291
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
1292 switch (wcd->rx_port_value[port_id]) {1295 switch (wcd->rx_port_value[port_id]) {
1293 case 0:1296 case 0:
1294 list_del_init(&wcd->rx_chs[port_id].list);1297 /* Channel already removed from lists. Nothing to do here */
1295 break;1298 break;
1296 case 1:1299 case 1:
1297 list_add_tail(&wcd->rx_chs[port_id].list,1300 list_add_tail(&wcd->rx_chs[port_id].list,