* [PATCH] Variable "val" in function rt274_i2c_probe() could be uninitialized
@ 2019-01-03 21:59 Yizhuo
2019-01-04 13:49 ` Mark Brown
0 siblings, 1 reply; 2+ messages in thread
From: Yizhuo @ 2019-01-03 21:59 UTC (permalink / raw)
Cc: csong, zhiyunq, Yizhuo, Bard Liao, Oder Chiou, Liam Girdwood,
Mark Brown, Jaroslav Kysela, Takashi Iwai, alsa-devel,
linux-kernel
Inside function rt274_i2c_probe(), if regmap_read() function
returns -EINVAL, then local variable "val" leaves uninitialized
but used in if statement. This is potentially unsafe.
Signed-off-by: Yizhuo <yzhai003@ucr.edu>
---
sound/soc/codecs/rt274.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/sound/soc/codecs/rt274.c b/sound/soc/codecs/rt274.c
index 8f92e5c4dd9d..cd048df76232 100644
--- a/sound/soc/codecs/rt274.c
+++ b/sound/soc/codecs/rt274.c
@@ -1128,8 +1128,11 @@ static int rt274_i2c_probe(struct i2c_client *i2c,
return ret;
}
- regmap_read(rt274->regmap,
+ ret = regmap_read(rt274->regmap,
RT274_GET_PARAM(AC_NODE_ROOT, AC_PAR_VENDOR_ID), &val);
+ if (ret)
+ return ret;
+
if (val != RT274_VENDOR_ID) {
dev_err(&i2c->dev,
"Device with ID register %#x is not rt274\n", val);
--
2.17.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] Variable "val" in function rt274_i2c_probe() could be uninitialized
2019-01-03 21:59 [PATCH] Variable "val" in function rt274_i2c_probe() could be uninitialized Yizhuo
@ 2019-01-04 13:49 ` Mark Brown
0 siblings, 0 replies; 2+ messages in thread
From: Mark Brown @ 2019-01-04 13:49 UTC (permalink / raw)
To: Yizhuo
Cc: csong, zhiyunq, Bard Liao, Oder Chiou, Liam Girdwood,
Jaroslav Kysela, Takashi Iwai, alsa-devel, linux-kernel
[-- Attachment #1: Type: text/plain, Size: 368 bytes --]
On Thu, Jan 03, 2019 at 01:59:12PM -0800, Yizhuo wrote:
> Inside function rt274_i2c_probe(), if regmap_read() function
> returns -EINVAL, then local variable "val" leaves uninitialized
> but used in if statement. This is potentially unsafe.
Please use subject lines matching the style for the subsystem. This
makes it easier for people to identify relevant patches.
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2019-01-04 13:50 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-01-03 21:59 [PATCH] Variable "val" in function rt274_i2c_probe() could be uninitialized Yizhuo
2019-01-04 13:49 ` Mark Brown
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).