Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1623765
| From | Douglas Anderson <dianders@chromium.org> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [PATCH 2/3] ASoC: rt5514: Avoid relying on uninitialized "val" value |
| Date | 2017-04-14 18:50 +0200 |
| Message-ID | <twcA1-3pr-5@gated-at.bofh.it> (permalink) |
| References | <twcA1-3pr-7@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
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>
---
sound/soc/codecs/rt5514.c | 6 +++---
1 file 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,
struct rt5514_platform_data *pdata = dev_get_platdata(&i2c->dev);
struct rt5514_priv *rt5514;
int ret;
- unsigned int val;
+ unsigned int val = ~0;
rt5514 = devm_kzalloc(&i2c->dev, sizeof(struct rt5514_priv),
GFP_KERNEL);
@@ -1120,8 +1120,8 @@ static int rt5514_i2c_probe(struct i2c_client *i2c,
return ret;
}
- regmap_read(rt5514->regmap, RT5514_VENDOR_ID2, &val);
- if (val != RT5514_DEVICE_ID) {
+ ret = regmap_read(rt5514->regmap, RT5514_VENDOR_ID2, &val);
+ if (ret || val != RT5514_DEVICE_ID) {
dev_err(&i2c->dev,
"Device with ID register %x is not rt5514\n", val);
return -ENODEV;
--
2.12.2.762.g0e3151a226-goog
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH 1/3] ASoC: rt5514: Mark rt5514_i2c_driver as static Douglas Anderson <dianders@chromium.org> - 2017-04-14 18:50 +0200
[PATCH 2/3] ASoC: rt5514: Avoid relying on uninitialized "val" value Douglas Anderson <dianders@chromium.org> - 2017-04-14 18:50 +0200
Applied "ASoC: rt5514: Avoid relying on uninitialized "val" value" to the asoc tree Mark Brown <broonie@kernel.org> - 2017-04-14 19:20 +0200
[PATCH 3/3] ASoC: rt5514: Unconfuse the rt5514 at probe / resume time Douglas Anderson <dianders@chromium.org> - 2017-04-14 18:50 +0200
Applied "ASoC: rt5514: Unconfuse the rt5514 at probe / resume time" to the asoc tree Mark Brown <broonie@kernel.org> - 2017-04-14 19:20 +0200
Applied "ASoC: rt5514: Mark rt5514_i2c_driver as static" to the asoc tree Mark Brown <broonie@kernel.org> - 2017-04-14 19:20 +0200
csiph-web