Skip to contentSkip to conversation

Fix oops in VIDIOC_G_PARM

PATCH New Jonathan Corbet 1 participant 1 message Oct 12, 2006 Media (V4L/DVB)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Fix oops in VIDIOC_G_PARM

The call to v4l2_std_construct() in the VIDIOC_G_PARM handler treats vfd->current_norm as if it were an index - but it's not. The result is an oops if the driver has no vidioc_g_parm() method defined. Here's the fix.

jon

drivers/media/video/videodev.c renamed from k/t/2.6.19-rc1/drivers/media/video/videodev.c +9 -2
@@ -1287,6 +1288,7 @@ static int __video_do_ioctl(struct inode
 			ret=vfd->vidioc_g_parm(file, fh, p);
 		} else {
 			struct v4l2_standard s;
+			int i;
 
 			if (!vfd->tvnormsize) {
 				printk (KERN_WARNING "%s: no TV norms defined!\n",
@@ -1297,8 +1299,14 @@ static int __video_do_ioctl(struct inode
 			if (p->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
 				return -EINVAL;
 
-			v4l2_video_std_construct(&s, vfd->tvnorms[vfd->current_norm].id,
-						 vfd->tvnorms[vfd->current_norm].name);
+			for (i = 0; i < vfd->tvnormsize; i++)
+				if (vfd->tvnorms[i].id == vfd->current_norm)
+					break;
+			if (i >= vfd->tvnormsize)
+				return -EINVAL;
+
+			v4l2_video_std_construct(&s, vfd->current_norm,
+						 vfd->tvnorms[i].name);
 
 			memset(p,0,sizeof(*p));