summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYizhuo <yzhai003@ucr.edu>2019-01-25 13:45:37 -0500
committerMark Brown <broonie@kernel.org>2019-01-28 07:34:39 -0500
commite20bfeb0b7d808bc05e7c4cb1f492cd31d837da0 (patch)
treedd510bc10a9dbf66038a01b537be197418e56b7a
parent5e484ec1758b95e6420787fc17f0e8c5e152c264 (diff)
ASoC: rt5651: Variable "ret" in function rt5651_i2c_probe() could be uninitialized
In function rt5651_i2c_probe(), local variable "ret" could be uninitialized if function regmap_read() returns -EINVAL. However, this value is used in if statement. This is potentially unsafe. Signed-off-by: Yizhuo <yzhai003@ucr.edu> Signed-off-by: Mark Brown <broonie@kernel.org>
-rw-r--r--sound/soc/codecs/rt5651.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/sound/soc/codecs/rt5651.c b/sound/soc/codecs/rt5651.c
index 75994297c896..29b2d60076b0 100644
--- a/sound/soc/codecs/rt5651.c
+++ b/sound/soc/codecs/rt5651.c
@@ -2181,6 +2181,7 @@ static int rt5651_i2c_probe(struct i2c_client *i2c,
2181{ 2181{
2182 struct rt5651_priv *rt5651; 2182 struct rt5651_priv *rt5651;
2183 int ret; 2183 int ret;
2184 int err;
2184 2185
2185 rt5651 = devm_kzalloc(&i2c->dev, sizeof(*rt5651), 2186 rt5651 = devm_kzalloc(&i2c->dev, sizeof(*rt5651),
2186 GFP_KERNEL); 2187 GFP_KERNEL);
@@ -2197,7 +2198,10 @@ static int rt5651_i2c_probe(struct i2c_client *i2c,
2197 return ret; 2198 return ret;
2198 } 2199 }
2199 2200
2200 regmap_read(rt5651->regmap, RT5651_DEVICE_ID, &ret); 2201 err = regmap_read(rt5651->regmap, RT5651_DEVICE_ID, &ret);
2202 if (err)
2203 return err;
2204
2201 if (ret != RT5651_DEVICE_ID_VALUE) { 2205 if (ret != RT5651_DEVICE_ID_VALUE) {
2202 dev_err(&i2c->dev, 2206 dev_err(&i2c->dev,
2203 "Device with ID register %#x is not rt5651\n", ret); 2207 "Device with ID register %#x is not rt5651\n", ret);