From: Hans de Goede <hdegoede@redhat.com>
To: Ricardo Ribalda <ribalda@chromium.org>,
Laurent Pinchart <laurent.pinchart@ideasonboard.com>,
Mauro Carvalho Chehab <mchehab@kernel.org>,
Guennadi Liakhovetski <guennadi.liakhovetski@intel.com>
Cc: Hans Verkuil <hverkuil@xs4all.nl>,
Mauro Carvalho Chehab <mchehab+samsung@kernel.org>,
linux-media@vger.kernel.org, linux-kernel@vger.kernel.org,
stable@vger.kernel.org
Subject: Re: [PATCH v5 1/5] media: uvcvideo: Only save async fh if success
Date: Mon, 2 Dec 2024 15:33:54 +0100 [thread overview]
Message-ID: <6acfcc52-c547-4823-b8e2-4555ddc64085@redhat.com> (raw)
In-Reply-To: <20241202-uvc-fix-async-v5-1-6658c1fe312b@chromium.org>
Hi,
On 2-Dec-24 3:24 PM, Ricardo Ribalda wrote:
> Now we keep a reference to the active fh for any call to uvc_ctrl_set,
> regardless if it is an actual set or if it is a just a try or if the
> device refused the operation.
>
> We should only keep the file handle if the device actually accepted
> applying the operation.
>
> Cc: stable@vger.kernel.org
> Fixes: e5225c820c05 ("media: uvcvideo: Send a control event when a Control Change interrupt arrives")
> Suggested-by: Hans de Goede <hdegoede@redhat.com>
> Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
Thank you, nice patch, better then my original suggestion :)
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
I'll let this sit on the list to give others a chance to reply
and if there are no remarks I'll merge this next Monday.
Regards,
Hans
> ---
> drivers/media/usb/uvc/uvc_ctrl.c | 18 +++++++++++-------
> 1 file changed, 11 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/media/usb/uvc/uvc_ctrl.c b/drivers/media/usb/uvc/uvc_ctrl.c
> index 4fe26e82e3d1..9a80a7d8e73a 100644
> --- a/drivers/media/usb/uvc/uvc_ctrl.c
> +++ b/drivers/media/usb/uvc/uvc_ctrl.c
> @@ -1811,7 +1811,10 @@ int uvc_ctrl_begin(struct uvc_video_chain *chain)
> }
>
> static int uvc_ctrl_commit_entity(struct uvc_device *dev,
> - struct uvc_entity *entity, int rollback, struct uvc_control **err_ctrl)
> + struct uvc_fh *handle,
> + struct uvc_entity *entity,
> + int rollback,
> + struct uvc_control **err_ctrl)
> {
> struct uvc_control *ctrl;
> unsigned int i;
> @@ -1859,6 +1862,10 @@ static int uvc_ctrl_commit_entity(struct uvc_device *dev,
> *err_ctrl = ctrl;
> return ret;
> }
> +
> + if (!rollback && handle &&
> + ctrl->info.flags & UVC_CTRL_FLAG_ASYNCHRONOUS)
> + ctrl->handle = handle;
> }
>
> return 0;
> @@ -1895,8 +1902,8 @@ int __uvc_ctrl_commit(struct uvc_fh *handle, int rollback,
>
> /* Find the control. */
> list_for_each_entry(entity, &chain->entities, chain) {
> - ret = uvc_ctrl_commit_entity(chain->dev, entity, rollback,
> - &err_ctrl);
> + ret = uvc_ctrl_commit_entity(chain->dev, handle, entity,
> + rollback, &err_ctrl);
> if (ret < 0) {
> if (ctrls)
> ctrls->error_idx =
> @@ -2046,9 +2053,6 @@ int uvc_ctrl_set(struct uvc_fh *handle,
> mapping->set(mapping, value,
> uvc_ctrl_data(ctrl, UVC_CTRL_DATA_CURRENT));
>
> - if (ctrl->info.flags & UVC_CTRL_FLAG_ASYNCHRONOUS)
> - ctrl->handle = handle;
> -
> ctrl->dirty = 1;
> ctrl->modified = 1;
> return 0;
> @@ -2377,7 +2381,7 @@ int uvc_ctrl_restore_values(struct uvc_device *dev)
> ctrl->dirty = 1;
> }
>
> - ret = uvc_ctrl_commit_entity(dev, entity, 0, NULL);
> + ret = uvc_ctrl_commit_entity(dev, NULL, entity, 0, NULL);
> if (ret < 0)
> return ret;
> }
>
next prev parent reply other threads:[~2024-12-02 14:34 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-12-02 14:24 [PATCH v5 0/5] media: uvcvideo: Two +1 fixes for async controls Ricardo Ribalda
2024-12-02 14:24 ` [PATCH v5 1/5] media: uvcvideo: Only save async fh if success Ricardo Ribalda
2024-12-02 14:33 ` Hans de Goede [this message]
2024-12-03 20:21 ` Laurent Pinchart
2024-12-02 14:24 ` [PATCH v5 2/5] media: uvcvideo: Remove dangling pointers Ricardo Ribalda
2024-12-02 14:44 ` Hans de Goede
2024-12-02 14:49 ` Ricardo Ribalda
2024-12-02 14:56 ` Hans de Goede
2024-12-03 20:35 ` Laurent Pinchart
2024-12-03 21:21 ` Ricardo Ribalda
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=6acfcc52-c547-4823-b8e2-4555ddc64085@redhat.com \
--to=hdegoede@redhat.com \
--cc=guennadi.liakhovetski@intel.com \
--cc=hverkuil@xs4all.nl \
--cc=laurent.pinchart@ideasonboard.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=mchehab+samsung@kernel.org \
--cc=mchehab@kernel.org \
--cc=ribalda@chromium.org \
--cc=stable@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox