Skip to content

Commit 92eb32d

Browse files
Sakari Ailusgregkh
authored andcommitted
media: v4l2-subdev: Fail {enable,disable}_streams and s_streaming nicely
commit 0bcbfd1 upstream. If a sub-device does not set enable_streams() and disable_streams() pad ops while it sets the s_stream() video op to v4l2_subdev_s_stream_helper(), enabling or disabling streaming either way on the sub-device will result calling v4l2_subdev_s_stream_helper() and v4l2_subdev_{enable,disable}_streams() recursively, exhausting the stack. Return -ENOIOCTLCMD in this case to handle the situation gracefully. Fixes: b62949d ("media: subdev: Support single-stream case in v4l2_subdev_enable/disable_streams()") Cc: stable@vger.kernel.org Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com> Reviewed-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent caea6bc commit 92eb32d

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

drivers/media/v4l2-core/v4l2-subdev.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2438,6 +2438,10 @@ int v4l2_subdev_s_stream_helper(struct v4l2_subdev *sd, int enable)
24382438
u64 source_mask = 0;
24392439
int pad_index = -1;
24402440

2441+
if (WARN_ON(!v4l2_subdev_has_op(sd, pad, enable_streams) ||
2442+
!v4l2_subdev_has_op(sd, pad, disable_streams)))
2443+
return -ENOIOCTLCMD;
2444+
24412445
/*
24422446
* Find the source pad. This helper is meant for subdevs that have a
24432447
* single source pad, so failures shouldn't happen, but catch them

0 commit comments

Comments
 (0)