Hi Hans, On Wed, Oct 25, 2023 at 11:32:11AM +0200, Hans Verkuil wrote: > On 23/10/2023 19:44, Sakari Ailus wrote: > > There are two sets of functions that return information from sub-device > > state, one for stream-unaware users and another for stream-aware users. > > Add support for stream-aware functions to return format, crop and compose > > information from pad-based array that are functionally equivalent to the > > old, stream-unaware ones. > > > > Also check state is non-NULL, in order to guard against old drivers > > potentially calling this with NULL state for active formats or selection > > rectangles. > > > > Signed-off-by: Sakari Ailus <sakari.ailus@xxxxxxxxxxxxxxx> > > --- > > drivers/media/v4l2-core/v4l2-subdev.c | 39 +++++++++++++++++++++++++++ > > include/media/v4l2-subdev.h | 9 ++++--- > > 2 files changed, 45 insertions(+), 3 deletions(-) > > > > diff --git a/drivers/media/v4l2-core/v4l2-subdev.c b/drivers/media/v4l2-core/v4l2-subdev.c > > index ee4fe8f33a41..955ee9a6c91f 100644 > > --- a/drivers/media/v4l2-core/v4l2-subdev.c > > +++ b/drivers/media/v4l2-core/v4l2-subdev.c > > @@ -1684,6 +1684,19 @@ v4l2_subdev_state_get_stream_format(struct v4l2_subdev_state *state, > > struct v4l2_subdev_stream_configs *stream_configs; > > unsigned int i; > > > > + if (WARN_ON(!state)) > > + return NULL; > > + > > + if (state->pads) { > > + if (stream) > > + return NULL; > > + > > + if (WARN_ON(pad >= state->sd->entity.num_pads)) > > + pad = 0; > > I saw Laurent's comment on why we don't return NULL here, and I think > based on your reply to that this will need a comment why we don't > return NULL (yet). It's weird code, and it needs an explanation. I can add a comment, sure. I'll also add a patch to just return NULL here in the set. -- Regards, Sakari Ailus