]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
ASoC: codecs: Fix atomicity violation in snd_soc_component_get_drvdata()
authorQiu-ji Chen <chenqiuji666@gmail.com>
Mon, 30 Sep 2024 10:12:16 +0000 (18:12 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 14 Dec 2024 18:51:13 +0000 (19:51 +0100)
commitf00012d5bf0c8a1b5a2329ea820185a1766f128b
tree776e4e3dfc9bd51d24084bb2f8b6238f8f088dd5
parent27a93c45e16ac25a0e2b5e5668e2d1beca56a478
ASoC: codecs: Fix atomicity violation in snd_soc_component_get_drvdata()

commit 1157733344651ca505e259d6554591ff156922fa upstream.

An atomicity violation occurs when the validity of the variables
da7219->clk_src and da7219->mclk_rate is being assessed. Since the entire
assessment is not protected by a lock, the da7219 variable might still be
in flux during the assessment, rendering this check invalid.

To fix this issue, we recommend adding a lock before the block
if ((da7219->clk_src == clk_id) && (da7219->mclk_rate == freq)) so that
the legitimacy check for da7219->clk_src and da7219->mclk_rate is
protected by the lock, ensuring the validity of the check.

This possible bug is found by an experimental static analysis tool
developed by our team. This tool analyzes the locking APIs
to extract function pairs that can be concurrently executed, and then
analyzes the instructions in the paired functions to identify possible
concurrency bugs including data races and atomicity violations.

Fixes: 6d817c0e9fd7 ("ASoC: codecs: Add da7219 codec driver")
Cc: stable@vger.kernel.org
Signed-off-by: Qiu-ji Chen <chenqiuji666@gmail.com>
Link: https://patch.msgid.link/20240930101216.23723-1-chenqiuji666@gmail.com
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
sound/soc/codecs/da7219.c