diff options
author | Douglas Anderson <dianders@chromium.org> | 2017-04-14 12:40:31 -0400 |
---|---|---|
committer | Mark Brown <broonie@kernel.org> | 2017-04-14 13:11:37 -0400 |
commit | 0a78b248c3324fbbba49f74e2c93e0f436583788 (patch) | |
tree | 90310071ac5889c401d7cf5b922aa44ba8f029c0 | |
parent | d0c02e14e48be94dd312ff6edffab9f9e6acd480 (diff) |
ASoC: rt5514: Avoid relying on uninitialized "val" value
In rt5514_i2c_probe() if the regmap_read(RT5514_VENDOR_ID2) fails then
"val" may be left as uninitialized. Current code relies on "val" not
being RT5514_DEVICE_ID, but that's potentially unsafe.
Let's check for errors from regmap_read() and also explicitly init the
value do we're not passing a possibly uninitialized int to printk.
Signed-off-by: Douglas Anderson <dianders@chromium.org>
Signed-off-by: Mark Brown <broonie@kernel.org>
-rw-r--r-- | sound/soc/codecs/rt5514.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/sound/soc/codecs/rt5514.c b/sound/soc/codecs/rt5514.c index 481e77763fe4..969a05620e04 100644 --- a/sound/soc/codecs/rt5514.c +++ b/sound/soc/codecs/rt5514.c | |||
@@ -1090,7 +1090,7 @@ static int rt5514_i2c_probe(struct i2c_client *i2c, | |||
1090 | struct rt5514_platform_data *pdata = dev_get_platdata(&i2c->dev); | 1090 | struct rt5514_platform_data *pdata = dev_get_platdata(&i2c->dev); |
1091 | struct rt5514_priv *rt5514; | 1091 | struct rt5514_priv *rt5514; |
1092 | int ret; | 1092 | int ret; |
1093 | unsigned int val; | 1093 | unsigned int val = ~0; |
1094 | 1094 | ||
1095 | rt5514 = devm_kzalloc(&i2c->dev, sizeof(struct rt5514_priv), | 1095 | rt5514 = devm_kzalloc(&i2c->dev, sizeof(struct rt5514_priv), |
1096 | GFP_KERNEL); | 1096 | GFP_KERNEL); |
@@ -1120,8 +1120,8 @@ static int rt5514_i2c_probe(struct i2c_client *i2c, | |||
1120 | return ret; | 1120 | return ret; |
1121 | } | 1121 | } |
1122 | 1122 | ||
1123 | regmap_read(rt5514->regmap, RT5514_VENDOR_ID2, &val); | 1123 | ret = regmap_read(rt5514->regmap, RT5514_VENDOR_ID2, &val); |
1124 | if (val != RT5514_DEVICE_ID) { | 1124 | if (ret || val != RT5514_DEVICE_ID) { |
1125 | dev_err(&i2c->dev, | 1125 | dev_err(&i2c->dev, |
1126 | "Device with ID register %x is not rt5514\n", val); | 1126 | "Device with ID register %x is not rt5514\n", val); |
1127 | return -ENODEV; | 1127 | return -ENODEV; |