Commit 5e6ff7c1 authored by Sakari Ailus's avatar Sakari Ailus Committed by Mauro Carvalho Chehab

[media] v4l: Check pad number in get try pointer functions

Unify functions to get try pointers and validate the pad number accessed by
the user.
Signed-off-by: default avatarSakari Ailus <sakari.ailus@iki.fi>
Acked-by: default avatarLaurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
parent c5a766ce
...@@ -565,23 +565,19 @@ struct v4l2_subdev_fh { ...@@ -565,23 +565,19 @@ struct v4l2_subdev_fh {
container_of(fh, struct v4l2_subdev_fh, vfh) container_of(fh, struct v4l2_subdev_fh, vfh)
#if defined(CONFIG_VIDEO_V4L2_SUBDEV_API) #if defined(CONFIG_VIDEO_V4L2_SUBDEV_API)
static inline struct v4l2_mbus_framefmt * #define __V4L2_SUBDEV_MK_GET_TRY(rtype, fun_name, field_name) \
v4l2_subdev_get_try_format(struct v4l2_subdev_fh *fh, unsigned int pad) static inline struct rtype * \
{ v4l2_subdev_get_try_##fun_name(struct v4l2_subdev_fh *fh, \
return &fh->pad[pad].try_fmt; unsigned int pad) \
} { \
BUG_ON(unlikely(pad >= vdev_to_v4l2_subdev( \
static inline struct v4l2_rect * fh->vfh.vdev)->entity.num_pads)); \
v4l2_subdev_get_try_crop(struct v4l2_subdev_fh *fh, unsigned int pad) return &fh->pad[pad].field_name; \
{ }
return &fh->pad[pad].try_crop;
} __V4L2_SUBDEV_MK_GET_TRY(v4l2_mbus_framefmt, format, try_fmt)
__V4L2_SUBDEV_MK_GET_TRY(v4l2_rect, crop, try_compose)
static inline struct v4l2_rect * __V4L2_SUBDEV_MK_GET_TRY(v4l2_rect, compose, try_compose)
v4l2_subdev_get_try_compose(struct v4l2_subdev_fh *fh, unsigned int pad)
{
return &fh->pad[pad].try_compose;
}
#endif #endif
extern const struct v4l2_file_operations v4l2_subdev_fops; extern const struct v4l2_file_operations v4l2_subdev_fops;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment