]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - releases/4.19.27/asoc-variable-val-in-function-rt274_i2c_probe-could-.patch
Linux 4.19.27
[thirdparty/kernel/stable-queue.git] / releases / 4.19.27 / asoc-variable-val-in-function-rt274_i2c_probe-could-.patch
1 From cf412fdc2e59b2cd48e079d7e7084aec4e065d06 Mon Sep 17 00:00:00 2001
2 From: Yizhuo <yzhai003@ucr.edu>
3 Date: Thu, 3 Jan 2019 13:59:12 -0800
4 Subject: ASoC: Variable "val" in function rt274_i2c_probe() could be
5 uninitialized
6
7 [ Upstream commit 8c3590de0a378c2449fc1aec127cc693632458e4 ]
8
9 Inside function rt274_i2c_probe(), if regmap_read() function
10 returns -EINVAL, then local variable "val" leaves uninitialized
11 but used in if statement. This is potentially unsafe.
12
13 Signed-off-by: Yizhuo <yzhai003@ucr.edu>
14 Signed-off-by: Mark Brown <broonie@kernel.org>
15 Signed-off-by: Sasha Levin <sashal@kernel.org>
16 ---
17 sound/soc/codecs/rt274.c | 5 ++++-
18 1 file changed, 4 insertions(+), 1 deletion(-)
19
20 diff --git a/sound/soc/codecs/rt274.c b/sound/soc/codecs/rt274.c
21 index d88e673410835..18a931c25ca58 100644
22 --- a/sound/soc/codecs/rt274.c
23 +++ b/sound/soc/codecs/rt274.c
24 @@ -1126,8 +1126,11 @@ static int rt274_i2c_probe(struct i2c_client *i2c,
25 return ret;
26 }
27
28 - regmap_read(rt274->regmap,
29 + ret = regmap_read(rt274->regmap,
30 RT274_GET_PARAM(AC_NODE_ROOT, AC_PAR_VENDOR_ID), &val);
31 + if (ret)
32 + return ret;
33 +
34 if (val != RT274_VENDOR_ID) {
35 dev_err(&i2c->dev,
36 "Device with ID register %#x is not rt274\n", val);
37 --
38 2.19.1
39