[media] v4l2-ioctl: fix incorrect error code if VIDIOC_DBG_G/S_REGISTER 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>
This commit is contained in:
Hans Verkuil 2011-01-08 09:53:32 -03:00 committed by Mauro Carvalho Chehab
parent 4c77590225
commit a1198ccf9c

View File

@ -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