From 2311072d9905b1f810a3c0665362ee552f076c26 Mon Sep 17 00:00:00 2001 From: Hans Verkuil Date: Thu, 8 Oct 2020 13:59:12 +0200 Subject: [PATCH] media: tvp7002: fix uninitialized variable warning tvp7002.c: In function 'tvp7002_g_register': tvp7002.c:691:11: warning: 'val' may be used uninitialized in this function [-Wmaybe-uninitialized] 691 | reg->val = val; | ~~~~~~~~~^~~~~ Just return without setting 'reg' if tvp7002_read returns an error. Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- drivers/media/i2c/tvp7002.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/media/i2c/tvp7002.c b/drivers/media/i2c/tvp7002.c index de313b1306da..ada4ec5ef782 100644 --- a/drivers/media/i2c/tvp7002.c +++ b/drivers/media/i2c/tvp7002.c @@ -688,9 +688,11 @@ static int tvp7002_g_register(struct v4l2_subdev *sd, int ret; ret = tvp7002_read(sd, reg->reg & 0xff, &val); + if (ret < 0) + return ret; reg->val = val; reg->size = 1; - return ret; + return 0; } /*