summary refs log tree commit diff
path: root/drivers/media/i2c/ov02a10.c
diff options
context:
space:
mode:
authorArnd Bergmann <arnd@arndb.de>2020-12-04 09:20:14 +0100
committerMauro Carvalho Chehab <mchehab+huawei@kernel.org>2020-12-07 13:54:58 +0100
commitcc17afa2e84f5017bae646a7240b6a43e847a2d7 (patch)
treeeb8a3235c7e4a29c28e1f0584c3390ec91314560 /drivers/media/i2c/ov02a10.c
parentf0f547272079a8ee2a3929909e1a7ae374b61e38 (diff)
downloadlinux-cc17afa2e84f5017bae646a7240b6a43e847a2d7.tar.gz
media: i2c: fix an uninitialized error code
Clang points out that the error handling in ov02a10_s_stream() is
broken, and just returns a random error code:

drivers/media/i2c/ov02a10.c:537:6: warning: variable 'ret' is used uninitialized whenever 'if' condition is true [-Wsometimes-uninitialized]
        if (ov02a10->streaming == on)
            ^~~~~~~~~~~~~~~~~~~~~~~~
drivers/media/i2c/ov02a10.c:568:9: note: uninitialized use occurs here
        return ret;
               ^~~
drivers/media/i2c/ov02a10.c:537:2: note: remove the 'if' if its condition is always false
        if (ov02a10->streaming == on)
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~

If streaming is already on, leave it that way and return success.

Suggested-by: Dongchun Zhu <dongchun.zhu@mediatek.com>
Fixes: 91807efbe8ec ("media: i2c: add OV02A10 image sensor driver")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Diffstat (limited to 'drivers/media/i2c/ov02a10.c')
-rw-r--r--drivers/media/i2c/ov02a10.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/drivers/media/i2c/ov02a10.c b/drivers/media/i2c/ov02a10.c
index 391718136ade..8683ffd3287a 100644
--- a/drivers/media/i2c/ov02a10.c
+++ b/drivers/media/i2c/ov02a10.c
@@ -534,8 +534,10 @@ static int ov02a10_s_stream(struct v4l2_subdev *sd, int on)
 
 	mutex_lock(&ov02a10->mutex);
 
-	if (ov02a10->streaming == on)
+	if (ov02a10->streaming == on) {
+		ret = 0;
 		goto unlock_and_return;
+	}
 
 	if (on) {
 		ret = pm_runtime_get_sync(&client->dev);