Thread (8 messages) 8 messages, 3 authors, 2009-03-30

Re: [linuxtv-commits] [hg:v4l-dvb] v4l2-ioctl: Check format for S_PARM and G_PARM

From: Hans Verkuil <hidden>
Date: 2009-03-29 09:06:25

On Sunday 29 March 2009 10:50:02 Patch from Trent Piepho wrote:
The patch number 11260 was added via Trent Piepho [off-list ref]
to http://linuxtv.org/hg/v4l-dvb master development tree.

Kernel patches in this development tree may be modified to be backward
compatible with older kernels. Compatibility modifications will be
removed before inclusion into the mainstream Kernel

If anyone has any objections, please let us know by sending a message to:
	Linux Media Mailing List [off-list ref]

------

From: Trent Piepho  <redacted>
v4l2-ioctl:  Check format for S_PARM and G_PARM


Return EINVAL if VIDIOC_S/G_PARM is called for a buffer type that the
driver doesn't define a ->vidioc_try_fmt_XXX() method for.  Several other
ioctls, like QUERYBUF, QBUF, and DQBUF, etc.  do this too.  It saves each
driver from having to check if the buffer type is one that it supports.
Hi Trent,

I wonder whether this change is correct. Looking at the spec I see that 
g/s_parm only supports VIDEO_CAPTURE, VIDEO_OUTPUT and PRIVATE or up.

So what should happen if the type is VIDEO_OVERLAY? I think the g/s_parm 
implementation in v4l2-ioctl.c should first exclude the unsupported types 
before calling check_fmt.

I also wonder whether check_fmt shouldn't check for the presence of the 
s_fmt callbacks instead of try_fmt since try_fmt is an optional ioctl.

Regards,

	Hans
quoted hunk
Priority: normal

Signed-off-by: Trent Piepho <redacted>


---

 linux/drivers/media/video/v4l2-ioctl.c |    7 +++++++
 1 file changed, 7 insertions(+)

diff -r 346bab8698ea -r 44632c5fe5b2
linux/drivers/media/video/v4l2-ioctl.c ---
a/linux/drivers/media/video/v4l2-ioctl.c	Sat Mar 28 18:25:35 2009 -0700
+++ b/linux/drivers/media/video/v4l2-ioctl.c	Sat Mar 28 18:25:35 2009
-0700 @@ -1552,6 +1552,9 @@ static long __video_do_ioctl(struct file
 		struct v4l2_streamparm *p = arg;

 		if (ops->vidioc_g_parm) {
+			ret = check_fmt(ops, p->type);
+			if (ret)
+				break;
 			ret = ops->vidioc_g_parm(file, fh, p);
 		} else {
 			if (p->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
@@ -1571,6 +1574,10 @@ static long __video_do_ioctl(struct file

 		if (!ops->vidioc_s_parm)
 			break;
+		ret = check_fmt(ops, p->type);
+		if (ret)
+			break;
+
 		dbgarg(cmd, "type=%d\n", p->type);
 		ret = ops->vidioc_s_parm(file, fh, p);
 		break;


---
Patch is available at:
http://linuxtv.org/hg/v4l-dvb/rev/44632c5fe5b2cd973c75501a88d61b43a39f6c4
3

_______________________________________________
linuxtv-commits mailing list
linuxtv-commits@linuxtv.org
http://www.linuxtv.org/cgi-bin/mailman/listinfo/linuxtv-commits


-- 
Hans Verkuil - video4linux developer - sponsored by TANDBERG
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help