Blob Blame History Raw
From b3244827d97c6659842544b9cc175631e13ae8f3 Mon Sep 17 00:00:00 2001
From: Peter Hutterer <peter.hutterer@who-t.net>
Date: Mon, 8 Oct 2018 13:06:41 +1000
Subject: [PATCH xf86-video-v4l 4/4] Fix ioctl return value handling

Found by coverity

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Dave Airlie <airlied@redhat.com>
---
 src/v4l.c | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/src/v4l.c b/src/v4l.c
index 8c2408c..9c6fabe 100644
--- a/src/v4l.c
+++ b/src/v4l.c
@@ -769,12 +769,15 @@ V4lSetPortAttribute(ScrnInfoPtr pScrn,
     } else if (attribute == xvFreq) {
         struct v4l2_frequency   freq;
         memset(&freq, 0, sizeof(freq));
-        ioctl(V4L_FD, VIDIOC_G_FREQUENCY, &freq);
-        freq.frequency = value;
-        if (ioctl(V4L_FD, VIDIOC_S_FREQUENCY, &freq) == -1)
-            xf86Msg(X_ERROR, "v4l: Error %d while setting frequency\n", errno);
-        else
-            ret = Success;
+        if (ioctl(V4L_FD, VIDIOC_G_FREQUENCY, &freq) == -1) {
+            xf86Msg(X_ERROR, "v4l: Error %d while getting frequency\n", errno);
+        } else {
+            freq.frequency = value;
+            if (ioctl(V4L_FD, VIDIOC_S_FREQUENCY, &freq) == -1)
+                xf86Msg(X_ERROR, "v4l: Error %d while setting frequency\n", errno);
+            else
+                ret = Success;
+        }
     } else {
         for (i = 0; i < pPPriv->n_qctrl; i++)
             if (pPPriv->XvV4LCtrl[i].xv == attribute)
-- 
2.17.1