v4l2: fill reserved fields of VIDIOC_ENUMAUDIO also

Message ID 49CA611B.5050902@freemail.hu (mailing list archive)
State Superseded, archived
Headers

Commit Message

Németh Márton March 25, 2009, 4:51 p.m. UTC
  From: Márton Németh <nm127@freemail.hu>

When enumerating audio inputs with VIDIOC_ENUMAUDIO the gspca_sunplus driver
does not fill the reserved fields of the struct v4l2_audio with zeros as
required by V4L2 API revision 0.24 [1]. Add the missing initializations to
the V4L2 framework.

The patch was tested with v4l-test 0.10 [2] with gspca_sunplus driver and
with Trust 610 LCD POWERC@M ZOOM webcam.

References:
[1] V4L2 API specification, revision 0.24
    http://v4l2spec.bytesex.org/spec/r8242.htm

[2] v4l-test: Test environment for Video For Linux Two API
    http://v4l-test.sourceforge.net/

Signed-off-by: Márton Németh <nm127@freemail.hu>
---
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
  

Comments

Mauro Carvalho Chehab March 27, 2009, 4:17 p.m. UTC | #1
On Wed, 25 Mar 2009 17:51:39 +0100
Németh Márton <nm127@freemail.hu> wrote:

> From: Márton Németh <nm127@freemail.hu>
> 
> When enumerating audio inputs with VIDIOC_ENUMAUDIO the gspca_sunplus driver
> does not fill the reserved fields of the struct v4l2_audio with zeros as
> required by V4L2 API revision 0.24 [1]. Add the missing initializations to
> the V4L2 framework.
> 
> The patch was tested with v4l-test 0.10 [2] with gspca_sunplus driver and
> with Trust 610 LCD POWERC@M ZOOM webcam.

It didn't apply against the development tree. Anyway, a recent patch removed
the need of memset there. the memory fill with zero now happens at the same
code we copy the structure values.

Cheers,
Mauro
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
  
Trent Piepho March 27, 2009, 7:45 p.m. UTC | #2
On Fri, 27 Mar 2009, Mauro Carvalho Chehab wrote:
> On Wed, 25 Mar 2009 17:51:39 +0100
> Németh Márton <nm127@freemail.hu> wrote:
>
> > From: Márton Németh <nm127@freemail.hu>
> >
> > When enumerating audio inputs with VIDIOC_ENUMAUDIO the gspca_sunplus driver
> > does not fill the reserved fields of the struct v4l2_audio with zeros as
> > required by V4L2 API revision 0.24 [1]. Add the missing initializations to
> > the V4L2 framework.
> >
> > The patch was tested with v4l-test 0.10 [2] with gspca_sunplus driver and
> > with Trust 610 LCD POWERC@M ZOOM webcam.
>
> It didn't apply against the development tree. Anyway, a recent patch removed
> the need of memset there. the memory fill with zero now happens at the same
> code we copy the structure values.

That code is in video_ioctl2, which gspca doesn't use.
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
  
Hans Verkuil March 27, 2009, 8:34 p.m. UTC | #3
On Friday 27 March 2009 20:45:40 Trent Piepho wrote:
> On Fri, 27 Mar 2009, Mauro Carvalho Chehab wrote:
> > On Wed, 25 Mar 2009 17:51:39 +0100
> >
> > Németh Márton <nm127@freemail.hu> wrote:
> > > From: Márton Németh <nm127@freemail.hu>
> > >
> > > When enumerating audio inputs with VIDIOC_ENUMAUDIO the gspca_sunplus
> > > driver does not fill the reserved fields of the struct v4l2_audio
> > > with zeros as required by V4L2 API revision 0.24 [1]. Add the missing
> > > initializations to the V4L2 framework.
> > >
> > > The patch was tested with v4l-test 0.10 [2] with gspca_sunplus driver
> > > and with Trust 610 LCD POWERC@M ZOOM webcam.
> >
> > It didn't apply against the development tree. Anyway, a recent patch
> > removed the need of memset there. the memory fill with zero now happens
> > at the same code we copy the structure values.
>
> That code is in video_ioctl2, which gspca doesn't use.

Yes, gspca does use video_ioctl2. You're probably confused with uvcvideo, 
which doesn't use it.

Regards,

	Hans
  
Trent Piepho March 27, 2009, 9:12 p.m. UTC | #4
On Fri, 27 Mar 2009, Hans Verkuil wrote:
> On Friday 27 March 2009 20:45:40 Trent Piepho wrote:
> > On Fri, 27 Mar 2009, Mauro Carvalho Chehab wrote:
> > > On Wed, 25 Mar 2009 17:51:39 +0100
> > >
> > > Németh Márton <nm127@freemail.hu> wrote:
> > > > From: Márton Németh <nm127@freemail.hu>
> > > >
> > > > When enumerating audio inputs with VIDIOC_ENUMAUDIO the gspca_sunplus
> > > > driver does not fill the reserved fields of the struct v4l2_audio
> > > > with zeros as required by V4L2 API revision 0.24 [1]. Add the missing
> > > > initializations to the V4L2 framework.
> > > >
> > > > The patch was tested with v4l-test 0.10 [2] with gspca_sunplus driver
> > > > and with Trust 610 LCD POWERC@M ZOOM webcam.
> > >
> > > It didn't apply against the development tree. Anyway, a recent patch
> > > removed the need of memset there. the memory fill with zero now happens
> > > at the same code we copy the structure values.
> >
> > That code is in video_ioctl2, which gspca doesn't use.
>
> Yes, gspca does use video_ioctl2. You're probably confused with uvcvideo,
> which doesn't use it.

You're right, I was thinking about Németh's earlier patches for the same
things in uvcvideo.  This patch wasn't for gspca anyway, it was for the
v4l2 core, and Mauro's right it's not necessary as my patch series fixed
all these problems.
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
  

Patch

--- linux-2.6.29/drivers/media/video/v4l2-ioctl.c.orig	2009-03-24 00:12:14.000000000 +0100
+++ linux-2.6.29/drivers/media/video/v4l2-ioctl.c	2009-03-25 17:11:27.000000000 +0100
@@ -1363,9 +1363,13 @@  static long __video_do_ioctl(struct file
 	case VIDIOC_ENUMAUDIO:
 	{
 		struct v4l2_audio *p = arg;
+		__u32 index = p->index;

 		if (!ops->vidioc_enumaudio)
 			break;
+
+		memset(p, 0, sizeof(*p));
+		p->index = index;
 		ret = ops->vidioc_enumaudio(file, fh, p);
 		if (!ret)
 			dbgarg(cmd, "index=%d, name=%s, capability=0x%x, "