* [PATCH] v4l2-ctrls: v4l2_ctrl_request_complete() should always set ref->req
@ 2020-03-03 10:34 Hans Verkuil
2020-03-05 14:06 ` Paul Kocialkowski
0 siblings, 1 reply; 2+ messages in thread
From: Hans Verkuil @ 2020-03-03 10:34 UTC (permalink / raw)
To: Linux Media Mailing List; +Cc: Paul Kocialkowski
When the request is completed, all controls are copied to the request object.
However, when VIDIOC_G_EXT_CTRLS attempts to read control values from the
request it will read the current value instead for any control reference that
has a NULL ref->req pointer. But that's wrong: after completing the request
*all* controls should have a non-NULL ref->req pointer since they are after
all copied to the request.
So set ref->req if it wasn't set already.
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Reported-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
---
diff --git a/drivers/media/v4l2-core/v4l2-ctrls.c b/drivers/media/v4l2-core/v4l2-ctrls.c
index 2928c5e0a73d..93d33d1db4e8 100644
--- a/drivers/media/v4l2-core/v4l2-ctrls.c
+++ b/drivers/media/v4l2-core/v4l2-ctrls.c
@@ -4296,10 +4296,17 @@ void v4l2_ctrl_request_complete(struct media_request *req,
continue;
v4l2_ctrl_lock(ctrl);
- if (ref->req)
+ if (ref->req) {
ptr_to_ptr(ctrl, ref->req->p_req, ref->p_req);
- else
+ } else {
ptr_to_ptr(ctrl, ctrl->p_cur, ref->p_req);
+ /*
+ * Set ref->req to ensure that when userspace wants to
+ * obtain the controls of this request it will take
+ * this value and not the current value of the control.
+ */
+ ref->req = ref;
+ }
v4l2_ctrl_unlock(ctrl);
}
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] v4l2-ctrls: v4l2_ctrl_request_complete() should always set ref->req
2020-03-03 10:34 [PATCH] v4l2-ctrls: v4l2_ctrl_request_complete() should always set ref->req Hans Verkuil
@ 2020-03-05 14:06 ` Paul Kocialkowski
0 siblings, 0 replies; 2+ messages in thread
From: Paul Kocialkowski @ 2020-03-05 14:06 UTC (permalink / raw)
To: Hans Verkuil; +Cc: Linux Media Mailing List
[-- Attachment #1: Type: text/plain, Size: 1687 bytes --]
Hi,
On Tue 03 Mar 20, 11:34, Hans Verkuil wrote:
> When the request is completed, all controls are copied to the request object.
> However, when VIDIOC_G_EXT_CTRLS attempts to read control values from the
> request it will read the current value instead for any control reference that
> has a NULL ref->req pointer. But that's wrong: after completing the request
> *all* controls should have a non-NULL ref->req pointer since they are after
> all copied to the request.
>
> So set ref->req if it wasn't set already.
Works fine here with this patch!
Tested-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
Cheers,
Paul
> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
> Reported-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
> ---
> diff --git a/drivers/media/v4l2-core/v4l2-ctrls.c b/drivers/media/v4l2-core/v4l2-ctrls.c
> index 2928c5e0a73d..93d33d1db4e8 100644
> --- a/drivers/media/v4l2-core/v4l2-ctrls.c
> +++ b/drivers/media/v4l2-core/v4l2-ctrls.c
> @@ -4296,10 +4296,17 @@ void v4l2_ctrl_request_complete(struct media_request *req,
> continue;
>
> v4l2_ctrl_lock(ctrl);
> - if (ref->req)
> + if (ref->req) {
> ptr_to_ptr(ctrl, ref->req->p_req, ref->p_req);
> - else
> + } else {
> ptr_to_ptr(ctrl, ctrl->p_cur, ref->p_req);
> + /*
> + * Set ref->req to ensure that when userspace wants to
> + * obtain the controls of this request it will take
> + * this value and not the current value of the control.
> + */
> + ref->req = ref;
> + }
> v4l2_ctrl_unlock(ctrl);
> }
>
--
Paul Kocialkowski, Bootlin
Embedded Linux and kernel engineering
https://bootlin.com
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-03-05 14:06 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-03 10:34 [PATCH] v4l2-ctrls: v4l2_ctrl_request_complete() should always set ref->req Hans Verkuil
2020-03-05 14:06 ` Paul Kocialkowski
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.