[PATCH xf86-video-v4l 4/4] Fix ioctl return value handling

Peter Hutterer peter.hutterer at who-t.net
Mon Oct 8 03:20:29 UTC 2018


Found by coverity

Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
 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



More information about the xorg-devel mailing list