* [PATCH] ASoC: rt5651: Variable "ret" in function rt5651_i2c_probe() could be uninitialized
@ 2019-01-25 18:45 Yizhuo
0 siblings, 0 replies; only message in thread
From: Yizhuo @ 2019-01-25 18:45 UTC (permalink / raw)
Cc: csong, zhiyunq, Yizhuo, Bard Liao, Oder Chiou, Liam Girdwood,
Mark Brown, Jaroslav Kysela, Takashi Iwai, alsa-devel,
linux-kernel
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>
---
sound/soc/codecs/rt5651.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/sound/soc/codecs/rt5651.c b/sound/soc/codecs/rt5651.c
index da60b28ba3df..8d6cbc6b6ff0 100644
--- a/sound/soc/codecs/rt5651.c
+++ b/sound/soc/codecs/rt5651.c
@@ -1734,6 +1734,7 @@ static int rt5651_i2c_probe(struct i2c_client *i2c,
struct rt5651_platform_data *pdata = dev_get_platdata(&i2c->dev);
struct rt5651_priv *rt5651;
int ret;
+ int err;
rt5651 = devm_kzalloc(&i2c->dev, sizeof(*rt5651),
GFP_KERNEL);
@@ -1755,7 +1756,10 @@ static int rt5651_i2c_probe(struct i2c_client *i2c,
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) {
dev_err(&i2c->dev,
"Device with ID register %#x is not rt5651\n", ret);
--
2.17.1
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2019-01-25 18:53 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-01-25 18:45 [PATCH] ASoC: rt5651: Variable "ret" in function rt5651_i2c_probe() could be uninitialized Yizhuo
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).