diff options
author | Yizhuo <yzhai003@ucr.edu> | 2019-01-07 23:12:32 +0300 |
---|---|---|
committer | Mark Brown <broonie@kernel.org> | 2019-01-08 16:05:48 +0300 |
commit | 4a8191aa9e057ea38279ef9e809265ba3966be40 (patch) | |
tree | 7baa4428e79a474db5997f01e8d3b1ed4b226f74 /sound/soc/codecs/rt274.c | |
parent | 7b57085a33ce55e28616f04fd9877ba2ca7e79de (diff) | |
download | linux-4a8191aa9e057ea38279ef9e809265ba3966be40.tar.xz |
ASoC: rt274: Variable "buf" in function rt274_jack_detect() could be uninitialized
In function rt274_jack_detect(), local variable "buf" could
be uninitialized if function regmap_read() returns -EINVAL.
However, it will be used to calculate "hp" and "mic" and
make their value unpredictable while those value are used
in the caller. This is potentially unsafe.
Signed-off-by: Yizhuo <yzhai003@ucr.edu>
Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'sound/soc/codecs/rt274.c')
-rw-r--r-- | sound/soc/codecs/rt274.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/sound/soc/codecs/rt274.c b/sound/soc/codecs/rt274.c index 9e88f7b25d38..adf59039a3b6 100644 --- a/sound/soc/codecs/rt274.c +++ b/sound/soc/codecs/rt274.c @@ -353,6 +353,7 @@ static void rt274_index_sync(struct snd_soc_component *component) static int rt274_jack_detect(struct rt274_priv *rt274, bool *hp, bool *mic) { unsigned int buf; + int ret; *hp = false; *mic = false; @@ -360,9 +361,15 @@ static int rt274_jack_detect(struct rt274_priv *rt274, bool *hp, bool *mic) if (!rt274->component) return -EINVAL; - regmap_read(rt274->regmap, RT274_GET_HP_SENSE, &buf); + ret = regmap_read(rt274->regmap, RT274_GET_HP_SENSE, &buf); + if (ret) + return ret; + *hp = buf & 0x80000000; - regmap_read(rt274->regmap, RT274_GET_MIC_SENSE, &buf); + ret = regmap_read(rt274->regmap, RT274_GET_MIC_SENSE, &buf); + if (ret) + return ret; + *mic = buf & 0x80000000; pr_debug("*hp = %d *mic = %d\n", *hp, *mic); |