From: Arnd Bergmann Date: Fri, 4 Dec 2020 08:20:14 +0000 (+0100) Subject: media: i2c: fix an uninitialized error code X-Git-Tag: howlett/maple_spf/20210104~393^2~64 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=cc17afa2e84f5017bae646a7240b6a43e847a2d7;p=users%2Fjedix%2Flinux-maple.git 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 Fixes: 91807efbe8ec ("media: i2c: add OV02A10 image sensor driver") Signed-off-by: Arnd Bergmann Signed-off-by: Sakari Ailus Signed-off-by: Mauro Carvalho Chehab --- 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);