mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-08-23 17:30:02 +00:00
media: v4l2-subdev.c: clear stream field
Both userspace and kernelspace can pass structs with an uninitialized 'stream' field. Since the check_state() function checks for a non-zero stream field, suddenly these calls will fails with -EINVAL. So check in the wrapper functions in v4l2-subdev.c (which are used by both the kernel and userspace API) if V4L2_SUBDEV_FL_STREAMS is set, and if not, then zero the stream field. Currently no drivers set V4L2_SUBDEV_FL_STREAMS, so the stream field will always be set to 0. This patch might well be reverted in the future when streams support is fully enabled and we finalized the userspace API support for this feature. Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
This commit is contained in:
parent
83e0f265aa
commit
68e87ebf26
1 changed files with 15 additions and 0 deletions
|
@ -197,6 +197,9 @@ static inline int check_format(struct v4l2_subdev *sd,
|
||||||
if (!format)
|
if (!format)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
|
if (!(sd->flags & V4L2_SUBDEV_FL_STREAMS))
|
||||||
|
format->stream = 0;
|
||||||
|
|
||||||
return check_which(format->which) ? : check_pad(sd, format->pad) ? :
|
return check_which(format->which) ? : check_pad(sd, format->pad) ? :
|
||||||
check_state(sd, state, format->which, format->pad, format->stream);
|
check_state(sd, state, format->which, format->pad, format->stream);
|
||||||
}
|
}
|
||||||
|
@ -224,6 +227,9 @@ static int call_enum_mbus_code(struct v4l2_subdev *sd,
|
||||||
if (!code)
|
if (!code)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
|
if (!(sd->flags & V4L2_SUBDEV_FL_STREAMS))
|
||||||
|
code->stream = 0;
|
||||||
|
|
||||||
return check_which(code->which) ? : check_pad(sd, code->pad) ? :
|
return check_which(code->which) ? : check_pad(sd, code->pad) ? :
|
||||||
check_state(sd, state, code->which, code->pad, code->stream) ? :
|
check_state(sd, state, code->which, code->pad, code->stream) ? :
|
||||||
sd->ops->pad->enum_mbus_code(sd, state, code);
|
sd->ops->pad->enum_mbus_code(sd, state, code);
|
||||||
|
@ -236,6 +242,9 @@ static int call_enum_frame_size(struct v4l2_subdev *sd,
|
||||||
if (!fse)
|
if (!fse)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
|
if (!(sd->flags & V4L2_SUBDEV_FL_STREAMS))
|
||||||
|
fse->stream = 0;
|
||||||
|
|
||||||
return check_which(fse->which) ? : check_pad(sd, fse->pad) ? :
|
return check_which(fse->which) ? : check_pad(sd, fse->pad) ? :
|
||||||
check_state(sd, state, fse->which, fse->pad, fse->stream) ? :
|
check_state(sd, state, fse->which, fse->pad, fse->stream) ? :
|
||||||
sd->ops->pad->enum_frame_size(sd, state, fse);
|
sd->ops->pad->enum_frame_size(sd, state, fse);
|
||||||
|
@ -271,6 +280,9 @@ static int call_enum_frame_interval(struct v4l2_subdev *sd,
|
||||||
if (!fie)
|
if (!fie)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
|
if (!(sd->flags & V4L2_SUBDEV_FL_STREAMS))
|
||||||
|
fie->stream = 0;
|
||||||
|
|
||||||
return check_which(fie->which) ? : check_pad(sd, fie->pad) ? :
|
return check_which(fie->which) ? : check_pad(sd, fie->pad) ? :
|
||||||
check_state(sd, state, fie->which, fie->pad, fie->stream) ? :
|
check_state(sd, state, fie->which, fie->pad, fie->stream) ? :
|
||||||
sd->ops->pad->enum_frame_interval(sd, state, fie);
|
sd->ops->pad->enum_frame_interval(sd, state, fie);
|
||||||
|
@ -283,6 +295,9 @@ static inline int check_selection(struct v4l2_subdev *sd,
|
||||||
if (!sel)
|
if (!sel)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
|
if (!(sd->flags & V4L2_SUBDEV_FL_STREAMS))
|
||||||
|
sel->stream = 0;
|
||||||
|
|
||||||
return check_which(sel->which) ? : check_pad(sd, sel->pad) ? :
|
return check_which(sel->which) ? : check_pad(sd, sel->pad) ? :
|
||||||
check_state(sd, state, sel->which, sel->pad, sel->stream);
|
check_state(sd, state, sel->which, sel->pad, sel->stream);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue