diff mbox series

Variable "val" in function rt274_i2c_probe() could be uninitialized

Message ID 20190103215912.6071-1-yzhai003@ucr.edu (mailing list archive)
State New, archived
Headers show
Series Variable "val" in function rt274_i2c_probe() could be uninitialized | expand

Commit Message

Yizhuo Zhai Jan. 3, 2019, 9:59 p.m. UTC
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 mbox series


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,
+	if (ret)
+		return ret;
 	if (val != RT274_VENDOR_ID) {
 			"Device with ID register %#x is not rt274\n", val);