mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-28 01:23:00 -04:00
media: v4l2-subdev: Verify arguments in v4l2_subdev_call()
Correctness of format type (try or active) and pad number parameters passed to subdevice operation callbacks is now verified only for IOCTL calls. However, those callbacks are also used by drivers, e.g., V4L2 host interfaces. Since both subdev_do_ioctl() and drivers are using v4l2_subdev_call() macro while calling subdevice operations, move those parameter checks from subdev_do_ioctl() to v4l2_subdev_call() so we can avoid taking care of those checks inside drivers. Define a wrapper function for each operation callback in scope, then gather those wrappers in a static v4l2_subdev_ops structure so the v4l2_subdev_call() macro can find them easy if provided. Signed-off-by: Janusz Krzysztofik <[email protected]> Reviewed-by: Sakari Ailus <[email protected]> Signed-off-by: Hans Verkuil <[email protected]> Signed-off-by: Mauro Carvalho Chehab <[email protected]>
This commit is contained in:
parent
b152a403a0
commit
a8fa55078a
2 changed files with 152 additions and 92 deletions
|
|
@ -1082,6 +1082,8 @@ void v4l2_subdev_free_pad_config(struct v4l2_subdev_pad_config *cfg);
|
|||
void v4l2_subdev_init(struct v4l2_subdev *sd,
|
||||
const struct v4l2_subdev_ops *ops);
|
||||
|
||||
extern const struct v4l2_subdev_ops v4l2_subdev_call_wrappers;
|
||||
|
||||
/**
|
||||
* v4l2_subdev_call - call an operation of a v4l2_subdev.
|
||||
*
|
||||
|
|
@ -1103,6 +1105,10 @@ void v4l2_subdev_init(struct v4l2_subdev *sd,
|
|||
__result = -ENODEV; \
|
||||
else if (!(__sd->ops->o && __sd->ops->o->f)) \
|
||||
__result = -ENOIOCTLCMD; \
|
||||
else if (v4l2_subdev_call_wrappers.o && \
|
||||
v4l2_subdev_call_wrappers.o->f) \
|
||||
__result = v4l2_subdev_call_wrappers.o->f( \
|
||||
__sd, ##args); \
|
||||
else \
|
||||
__result = __sd->ops->o->f(__sd, ##args); \
|
||||
__result; \
|
||||
|
|
|
|||
Loading…
Reference in a new issue