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>
This commit is contained in:
Yizhuo 2019-01-25 10:45:37 -08:00 committed by Mark Brown
parent 5e484ec175
commit e20bfeb0b7
No known key found for this signature in database
GPG Key ID: 24D68B725D5487D0
1 changed files with 5 additions and 1 deletions

View File

@ -2181,6 +2181,7 @@ static int rt5651_i2c_probe(struct i2c_client *i2c,
{ {
struct rt5651_priv *rt5651; struct rt5651_priv *rt5651;
int ret; int ret;
int err;
rt5651 = devm_kzalloc(&i2c->dev, sizeof(*rt5651), rt5651 = devm_kzalloc(&i2c->dev, sizeof(*rt5651),
GFP_KERNEL); GFP_KERNEL);
@ -2197,7 +2198,10 @@ static int rt5651_i2c_probe(struct i2c_client *i2c,
return ret; return ret;
} }
regmap_read(rt5651->regmap, RT5651_DEVICE_ID, &ret); err = regmap_read(rt5651->regmap, RT5651_DEVICE_ID, &ret);
if (err)
return err;
if (ret != RT5651_DEVICE_ID_VALUE) { if (ret != RT5651_DEVICE_ID_VALUE) {
dev_err(&i2c->dev, dev_err(&i2c->dev,
"Device with ID register %#x is not rt5651\n", ret); "Device with ID register %#x is not rt5651\n", ret);