media: uvcvideo: Do not return positive errors in uvc_query_ctrl()
authorRicardo Ribalda <ribalda@chromium.org>
Tue, 3 Jan 2023 14:36:22 +0000 (15:36 +0100)
committerLaurent Pinchart <laurent.pinchart@ideasonboard.com>
Sun, 15 Jan 2023 21:45:12 +0000 (23:45 +0200)
If the returned size of the query does not match the expected size or it
is zero, return -EPIPE instead of 0 or a positive value.

This will avoid confusing the caller (and ultimately userspace) that
doesn't expect a positive or zero value.

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Suggested-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
drivers/media/usb/uvc/uvc_video.c

index 3d3753a4c1f84b3bee848b99a1b9d1e0f1d22ac4..e4b71df08216bf20aa670f4d5cd7f5a215a60b33 100644 (file)
@@ -83,7 +83,7 @@ int uvc_query_ctrl(struct uvc_device *dev, u8 query, u8 unit,
                dev_err(&dev->udev->dev,
                        "Failed to query (%s) UVC control %u on unit %u: %d (exp. %u).\n",
                        uvc_query_name(query), cs, unit, ret, size);
-               return ret;
+               return ret < 0 ? ret : -EPIPE;
        }
 
        /* Reuse data[0] to request the error code. */