Subject: CVE-2021-47502: ASoC: codecs: wcd934x: handle channel mappping list correctly

From: Greg Kroah-Hartman <[email-masked]>

Description
===========

In the Linux kernel, the following vulnerability has been resolved:

ASoC: codecs: wcd934x: handle channel mappping list correctly

Currently each channel is added as list to dai channel list, however
there is danger of adding same channel to multiple dai channel list
which endups corrupting the other list where its already added.

This patch ensures that the channel is actually free before adding to
the dai channel list and also ensures that the channel is on the list
before deleting it.

This check was missing previously, and we did not hit this issue as
we were testing very simple usecases with sequence of amixer commands.

The Linux kernel CVE team has assigned CVE-2021-47502 to this issue.

Affected and fixed versions
===========================

	Issue introduced in 5.6 with commit a70d9245759a and fixed in 5.10.85 with commit 1089dac26c6b
	Issue introduced in 5.6 with commit a70d9245759a and fixed in 5.15.8 with commit 339ffb5b5600
	Issue introduced in 5.6 with commit a70d9245759a and fixed in 5.16 with commit 23ba28616d30

Please see https://www.kernel.org for a full list of currently supported
kernel versions by the kernel community.

Unaffected versions might change over time as fixes are backported to
older supported kernel versions.  The official CVE entry at
	https://cve.org/CVERecord/?id=CVE-2021-47502
will be updated if fixes are backported, please check that for the most
up to date information about this issue.

Affected files
==============

The file(s) affected by this issue are:
	sound/soc/codecs/wcd934x.c

Mitigation
==========

The Linux kernel CVE team recommends that you update to the latest
stable kernel version for this, and many other bugfixes.  Individual
changes are never tested alone, but rather are part of a larger kernel
release.  Cherry-picking individual commits is not recommended or
supported by the Linux kernel community at all.  If however, updating to
the latest release is impossible, the individual changes to resolve this
issue can be found at these commits:
	https://git.kernel.org/stable/c/1089dac26c6b4b833323ae6c0ceab29fb30ede72
	https://git.kernel.org/stable/c/339ffb5b56005582aacc860524d2d208604049d1
	https://git.kernel.org/stable/c/23ba28616d3063bd4c4953598ed5e439ca891101