media: tw5864: check status of tw5864_frameinterval_get
authorTom Rix <trix@redhat.com>
Mon, 10 Aug 2020 19:25:18 +0000 (21:25 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 5 Nov 2020 10:06:55 +0000 (11:06 +0100)
[ Upstream commit 780d815dcc9b34d93ae69385a8465c38d423ff0f ]

clang static analysis reports this problem

tw5864-video.c:773:32: warning: The left expression of the compound
  assignment is an uninitialized value.
  The computed value will also be garbage
        fintv->stepwise.max.numerator *= std_max_fps;
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^

stepwise.max is set with frameinterval, which comes from

ret = tw5864_frameinterval_get(input, &frameinterval);
fintv->stepwise.step = frameinterval;
fintv->stepwise.min = frameinterval;
fintv->stepwise.max = frameinterval;
fintv->stepwise.max.numerator *= std_max_fps;

When tw5864_frameinterval_get() fails, frameinterval is not
set. So check the status and fix another similar problem.

Signed-off-by: Tom Rix <trix@redhat.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/media/pci/tw5864/tw5864-video.c

index ee1230440b397e3b2e55f1f59e04e461dd6f0efc..02258685800a7e06ef8f6eb59780ddbc6c9b7481 100644 (file)
@@ -776,6 +776,9 @@ static int tw5864_enum_frameintervals(struct file *file, void *priv,
        fintv->type = V4L2_FRMIVAL_TYPE_STEPWISE;
 
        ret = tw5864_frameinterval_get(input, &frameinterval);
+       if (ret)
+               return ret;
+
        fintv->stepwise.step = frameinterval;
        fintv->stepwise.min = frameinterval;
        fintv->stepwise.max = frameinterval;
@@ -794,6 +797,9 @@ static int tw5864_g_parm(struct file *file, void *priv,
        cp->capability = V4L2_CAP_TIMEPERFRAME;
 
        ret = tw5864_frameinterval_get(input, &cp->timeperframe);
+       if (ret)
+               return ret;
+
        cp->timeperframe.numerator *= input->frame_interval;
        cp->capturemode = 0;
        cp->readbuffers = 2;