Skip to content

Commit

Permalink
[media] v4l2-ioctl: fix incorrect error code if VIDIOC_DBG_G/S_REGIST…
Browse files Browse the repository at this point in the history
…ER are unsupported

The ioctls VIDIOC_DBG_S_REGISTER and VIDIOC_DBG_G_REGISTER should return -EINVAL
if the driver didn't implement them. Currently they return -EPERM if called as
non-root user. However, this check should only be done if the driver actually
implemented these ioctls. Otherwise, just return -EINVAL as we do with all
unimplemented ioctls.

This bug make the v4l2-compliance test suite fail.

Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
  • Loading branch information
Hans Verkuil authored and Mauro Carvalho Chehab committed Jan 19, 2011
1 parent 4c77590 commit a1198cc
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions drivers/media/video/v4l2-ioctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -1659,20 +1659,24 @@ static long __video_do_ioctl(struct file *file,
{
struct v4l2_dbg_register *p = arg;

if (!capable(CAP_SYS_ADMIN))
ret = -EPERM;
else if (ops->vidioc_g_register)
ret = ops->vidioc_g_register(file, fh, p);
if (ops->vidioc_g_register) {
if (!capable(CAP_SYS_ADMIN))
ret = -EPERM;
else
ret = ops->vidioc_g_register(file, fh, p);
}
break;
}
case VIDIOC_DBG_S_REGISTER:
{
struct v4l2_dbg_register *p = arg;

if (!capable(CAP_SYS_ADMIN))
ret = -EPERM;
else if (ops->vidioc_s_register)
ret = ops->vidioc_s_register(file, fh, p);
if (ops->vidioc_s_register) {
if (!capable(CAP_SYS_ADMIN))
ret = -EPERM;
else
ret = ops->vidioc_s_register(file, fh, p);
}
break;
}
#endif
Expand Down

0 comments on commit a1198cc

Please sign in to comment.