Hi Sakari, Thank you for the patch. On Sat, May 06, 2023 at 12:52:54AM +0300, Sakari Ailus wrote: > Check the validity of pad flags on entity init. Exactly one of the flags > must be set. > > Signed-off-by: Sakari Ailus <sakari.ailus@xxxxxxxxxxxxxxx> > --- > drivers/media/mc/mc-entity.c | 12 +++++++++++- > 1 file changed, 11 insertions(+), 1 deletion(-) > > diff --git a/drivers/media/mc/mc-entity.c b/drivers/media/mc/mc-entity.c > index ed99160a2487..c1bc48c4d239 100644 > --- a/drivers/media/mc/mc-entity.c > +++ b/drivers/media/mc/mc-entity.c > @@ -197,6 +197,7 @@ int media_entity_pads_init(struct media_entity *entity, u16 num_pads, > struct media_device *mdev = entity->graph_obj.mdev; > struct media_pad *iter; > unsigned int i = 0; > + int ret = 0; > > if (num_pads >= MEDIA_ENTITY_MAX_PADS) > return -E2BIG; > @@ -210,6 +211,15 @@ int media_entity_pads_init(struct media_entity *entity, u16 num_pads, > media_entity_for_each_pad(entity, iter) { > iter->entity = entity; > iter->index = i++; > + > + if (hweight32(iter->flags & (MEDIA_PAD_FL_SINK | > + MEDIA_PAD_FL_SOURCE | > + MEDIA_PAD_FL_INTERNAL_SOURCE)) > + != 1) { I would add this check as patch 1/7 in this series, with FL_SINK an FL_SOURCE only, and then extend it in the patch where you introduce FL_INTERNAL_SOURCE. > + ret = -EINVAL; > + break; > + } > + > if (mdev) > media_gobj_create(mdev, MEDIA_GRAPH_PAD, > &iter->graph_obj); > @@ -218,7 +228,7 @@ int media_entity_pads_init(struct media_entity *entity, u16 num_pads, > if (mdev) > mutex_unlock(&mdev->graph_mutex); > > - return 0; > + return ret; > } > EXPORT_SYMBOL_GPL(media_entity_pads_init); > -- Regards, Laurent Pinchart