aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/v4l2-core/v4l2-subdev.c
diff options
context:
space:
mode:
authorLad Prabhakar <[email protected]>2024-10-07 12:38:09 +0000
committerMauro Carvalho Chehab <[email protected]>2024-10-16 07:32:41 +0000
commitafdb1f1fefb43a1bc16f203d1bac92e81fc60d89 (patch)
treef93d1e95db1ca0e69f58df01ce85fe02b5d872e2 /drivers/media/v4l2-core/v4l2-subdev.c
parentmedia: i2c: ds90ub960: Fix missing return check on ub960_rxport_read call (diff)
downloadkernel-afdb1f1fefb43a1bc16f203d1bac92e81fc60d89.tar.gz
kernel-afdb1f1fefb43a1bc16f203d1bac92e81fc60d89.zip
v4l2-subdev: Return -EOPNOTSUPP for unsupported pad type in call_get_frame_desc()
The `get_frame_desc()` operation should always be called on a source pad, which is indicated by the `MEDIA_PAD_FL_SOURCE` flag. This patch adds a check in `call_get_frame_desc()` to ensure that the `MEDIA_PAD_FL_SOURCE` flag is set for the pad before invoking `get_frame_desc()`. If the pad is not a source pad, the function will return an `-EOPNOTSUPP` error, signaling that the operation is not supported on non-source pads. Suggested-by: Sakari Ailus <[email protected]> Signed-off-by: Lad Prabhakar <[email protected]> Reviewed-by: Laurent Pinchart <[email protected]> Signed-off-by: Sakari Ailus <[email protected]> Signed-off-by: Mauro Carvalho Chehab <[email protected]>
Diffstat (limited to 'drivers/media/v4l2-core/v4l2-subdev.c')
-rw-r--r--drivers/media/v4l2-core/v4l2-subdev.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/drivers/media/v4l2-core/v4l2-subdev.c b/drivers/media/v4l2-core/v4l2-subdev.c
index 3a4ba08810d2..827b3b8918cb 100644
--- a/drivers/media/v4l2-core/v4l2-subdev.c
+++ b/drivers/media/v4l2-core/v4l2-subdev.c
@@ -334,6 +334,11 @@ static int call_get_frame_desc(struct v4l2_subdev *sd, unsigned int pad,
unsigned int i;
int ret;
+#if defined(CONFIG_MEDIA_CONTROLLER)
+ if (!(sd->entity.pads[pad].flags & MEDIA_PAD_FL_SOURCE))
+ return -EOPNOTSUPP;
+#endif
+
memset(fd, 0, sizeof(*fd));
ret = sd->ops->pad->get_frame_desc(sd, pad, fd);