As warned by smatch:
        drivers/media/i2c/s5c73m3/s5c73m3-core.c:268 s5c73m3_check_status() 
error: uninitialized symbol 'status'.

if s5c73m3_check_status() is called too late, time_is_after_jiffies(end)
will return 0, causing the while to abort before reading status.

The current code will do the wrong thing here, as it will still
check if status != value. The right fix here is to just change
the initial state of ret to -ETIMEDOUT. This way, if the
routine is called too late, it will skip the flawed check
and return that a timeout happened.

Signed-off-by: Mauro Carvalho Chehab <mche...@s-opensource.com>
---
 drivers/media/i2c/s5c73m3/s5c73m3-core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/i2c/s5c73m3/s5c73m3-core.c 
b/drivers/media/i2c/s5c73m3/s5c73m3-core.c
index cdc4f2392ef9..45345f8b27a5 100644
--- a/drivers/media/i2c/s5c73m3/s5c73m3-core.c
+++ b/drivers/media/i2c/s5c73m3/s5c73m3-core.c
@@ -248,7 +248,7 @@ static int s5c73m3_check_status(struct s5c73m3 *state, 
unsigned int value)
 {
        unsigned long start = jiffies;
        unsigned long end = start + msecs_to_jiffies(2000);
-       int ret = 0;
+       int ret = -ETIMEDOUT;
        u16 status;
        int count = 0;
 
-- 
2.13.6

Reply via email to