提交 a1198ccf 编写于 作者: H Hans Verkuil 提交者: Mauro Carvalho Chehab

[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: NHans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: NMauro Carvalho Chehab <mchehab@redhat.com>
上级 4c775902
......@@ -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
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册