]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/commitdiff
4.19-stable patches
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 13 Aug 2024 16:16:31 +0000 (18:16 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 13 Aug 2024 16:16:31 +0000 (18:16 +0200)
added patches:
media-uvcvideo-use-entity-get_cur-in-uvc_ctrl_set.patch

queue-4.19/media-uvcvideo-use-entity-get_cur-in-uvc_ctrl_set.patch [new file with mode: 0644]
queue-4.19/series

diff --git a/queue-4.19/media-uvcvideo-use-entity-get_cur-in-uvc_ctrl_set.patch b/queue-4.19/media-uvcvideo-use-entity-get_cur-in-uvc_ctrl_set.patch
new file mode 100644 (file)
index 0000000..ddc0d5c
--- /dev/null
@@ -0,0 +1,129 @@
+From 5f36851c36b30f713f588ed2b60aa7b4512e2c76 Mon Sep 17 00:00:00 2001
+From: Yunke Cao <yunkec@google.com>
+Date: Thu, 7 Jul 2022 10:53:31 +0200
+Subject: media: uvcvideo: Use entity get_cur in uvc_ctrl_set
+
+From: Yunke Cao <yunkec@google.com>
+
+commit 5f36851c36b30f713f588ed2b60aa7b4512e2c76 upstream.
+
+Entity controls should get_cur using an entity-defined function
+instead of via a query. Fix this in uvc_ctrl_set.
+
+Fixes: 65900c581d01 ("media: uvcvideo: Allow entity-defined get_info and get_cur")
+Signed-off-by: Yunke Cao <yunkec@google.com>
+Reviewed-by: Ricardo Ribalda <ribalda@chromium.org>
+Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
+Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ drivers/media/usb/uvc/uvc_ctrl.c |   83 +++++++++++++++++++++------------------
+ 1 file changed, 46 insertions(+), 37 deletions(-)
+
+--- a/drivers/media/usb/uvc/uvc_ctrl.c
++++ b/drivers/media/usb/uvc/uvc_ctrl.c
+@@ -997,36 +997,56 @@ static s32 __uvc_ctrl_get_value(struct u
+       return value;
+ }
+-static int __uvc_ctrl_get(struct uvc_video_chain *chain,
+-      struct uvc_control *ctrl, struct uvc_control_mapping *mapping,
+-      s32 *value)
++static int __uvc_ctrl_load_cur(struct uvc_video_chain *chain,
++                             struct uvc_control *ctrl)
+ {
++      u8 *data;
+       int ret;
+-      if ((ctrl->info.flags & UVC_CTRL_FLAG_GET_CUR) == 0)
+-              return -EACCES;
++      if (ctrl->loaded)
++              return 0;
+-      if (!ctrl->loaded) {
+-              if (ctrl->entity->get_cur) {
+-                      ret = ctrl->entity->get_cur(chain->dev,
+-                              ctrl->entity,
+-                              ctrl->info.selector,
+-                              uvc_ctrl_data(ctrl, UVC_CTRL_DATA_CURRENT),
+-                              ctrl->info.size);
+-              } else {
+-                      ret = uvc_query_ctrl(chain->dev, UVC_GET_CUR,
+-                              ctrl->entity->id,
+-                              chain->dev->intfnum,
+-                              ctrl->info.selector,
+-                              uvc_ctrl_data(ctrl, UVC_CTRL_DATA_CURRENT),
+-                              ctrl->info.size);
+-              }
+-              if (ret < 0)
+-                      return ret;
++      data = uvc_ctrl_data(ctrl, UVC_CTRL_DATA_CURRENT);
++      if ((ctrl->info.flags & UVC_CTRL_FLAG_GET_CUR) == 0) {
++              memset(data, 0, ctrl->info.size);
+               ctrl->loaded = 1;
++
++              return 0;
+       }
++      if (ctrl->entity->get_cur)
++              ret = ctrl->entity->get_cur(chain->dev, ctrl->entity,
++                                          ctrl->info.selector, data,
++                                          ctrl->info.size);
++      else
++              ret = uvc_query_ctrl(chain->dev, UVC_GET_CUR,
++                                   ctrl->entity->id, chain->dev->intfnum,
++                                   ctrl->info.selector, data,
++                                   ctrl->info.size);
++
++      if (ret < 0)
++              return ret;
++
++      ctrl->loaded = 1;
++
++      return ret;
++}
++
++static int __uvc_ctrl_get(struct uvc_video_chain *chain,
++                        struct uvc_control *ctrl,
++                        struct uvc_control_mapping *mapping,
++                        s32 *value)
++{
++      int ret;
++
++      if ((ctrl->info.flags & UVC_CTRL_FLAG_GET_CUR) == 0)
++              return -EACCES;
++
++      ret = __uvc_ctrl_load_cur(chain, ctrl);
++      if (ret < 0)
++              return ret;
++
+       *value = __uvc_ctrl_get_value(mapping,
+                               uvc_ctrl_data(ctrl, UVC_CTRL_DATA_CURRENT));
+@@ -1680,21 +1700,10 @@ int uvc_ctrl_set(struct uvc_fh *handle,
+        * needs to be loaded from the device to perform the read-modify-write
+        * operation.
+        */
+-      if (!ctrl->loaded && (ctrl->info.size * 8) != mapping->size) {
+-              if ((ctrl->info.flags & UVC_CTRL_FLAG_GET_CUR) == 0) {
+-                      memset(uvc_ctrl_data(ctrl, UVC_CTRL_DATA_CURRENT),
+-                              0, ctrl->info.size);
+-              } else {
+-                      ret = uvc_query_ctrl(chain->dev, UVC_GET_CUR,
+-                              ctrl->entity->id, chain->dev->intfnum,
+-                              ctrl->info.selector,
+-                              uvc_ctrl_data(ctrl, UVC_CTRL_DATA_CURRENT),
+-                              ctrl->info.size);
+-                      if (ret < 0)
+-                              return ret;
+-              }
+-
+-              ctrl->loaded = 1;
++      if ((ctrl->info.size * 8) != mapping->size) {
++              ret = __uvc_ctrl_load_cur(chain, ctrl);
++              if (ret < 0)
++                      return ret;
+       }
+       /* Backup the current value in case we need to rollback later. */
index 0f6c4973530d956e230aa5fbe831c8b4a4f4b81b..e9714a88be22e6cfc85b3f2192db04d620dbe440 100644 (file)
@@ -190,3 +190,4 @@ netfilter-nf_tables-set-element-extended-ack-reporting-support.patch
 netfilter-nf_tables-use-timestamp-to-check-for-set-element-timeout.patch
 netfilter-nf_tables-prefer-nft_chain_validate.patch
 arm64-cpufeature-fix-the-visibility-of-compat-hwcaps.patch
+media-uvcvideo-use-entity-get_cur-in-uvc_ctrl_set.patch