All of lore.kernel.org
 help / color / mirror / Atom feed
From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
To: Sakari Ailus <sakari.ailus@linux.intel.com>
Cc: linux-media@vger.kernel.org, Tianshu Qiu <tian.shu.qiu@intel.com>,
	Bingbu Cao <bingbu.cao@intel.com>,
	Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>,
	Jacopo Mondi <jacopo+renesas@jmondi.org>,
	Rui Miguel Silva <rmfrfs@gmail.com>,
	Martin Kepplinger <martink@posteo.de>
Subject: Re: [PATCH v3 12/12] media: mc: Check pad flag validity
Date: Tue, 19 Sep 2023 16:26:57 +0300	[thread overview]
Message-ID: <20230919132657.GC1505@pendragon.ideasonboard.com> (raw)
In-Reply-To: <20230919121728.126781-13-sakari.ailus@linux.intel.com>

Hi Sakari,

Thank you for the patch.

On Tue, Sep 19, 2023 at 03:17:28PM +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@linux.intel.com>
> ---
>  drivers/media/mc/mc-entity.c | 14 +++++++++++++-
>  1 file changed, 13 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/media/mc/mc-entity.c b/drivers/media/mc/mc-entity.c
> index 83468d4a440b..0a54cf8bcca2 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,15 +211,26 @@ 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)) != 1) {
> +			ret = -EINVAL;
> +			break;
> +		}
> +
>  		if (mdev)
>  			media_gobj_create(mdev, MEDIA_GRAPH_PAD,
>  					  &iter->graph_obj);
>  	}
>  
> +	if (ret && mdev)
> +		media_entity_for_each_pad(entity, iter)
> +			media_gobj_destroy(&iter->graph_obj);

With curly braces for the if () { ... },

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

> +
>  	if (mdev)
>  		mutex_unlock(&mdev->graph_mutex);
>  
> -	return 0;
> +	return ret;
>  }
>  EXPORT_SYMBOL_GPL(media_entity_pads_init);
>  

-- 
Regards,

Laurent Pinchart

      reply	other threads:[~2023-09-19 13:26 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-19 12:17 [PATCH v3 00/12] Small fixes and cleanups (ov2740 and ccs) Sakari Ailus
2023-09-19 12:17 ` [PATCH v3 01/12] media: Documentation: Align numbered list, make it a proper ReST Sakari Ailus
2023-09-19 12:17 ` [PATCH v3 02/12] media: ccs: Fix driver quirk struct documentation Sakari Ailus
2023-09-19 12:17 ` [PATCH v3 03/12] media: ccs: Correctly initialise try compose rectangle Sakari Ailus
2023-09-19 12:17 ` [PATCH v3 04/12] media: ccs: Correct error handling in ccs_register_subdev Sakari Ailus
2023-09-19 12:17 ` [PATCH v3 05/12] media: ccs: Switch to init_cfg Sakari Ailus
2023-09-19 12:17 ` [PATCH v3 06/12] media: ccs: Use sub-device active state Sakari Ailus
2023-09-19 12:17 ` [PATCH v3 07/12] media: ov2740: Enable runtime PM before registering the async subdev Sakari Ailus
2023-09-19 12:17 ` [PATCH v3 08/12] media: ov2740: Use sub-device active state Sakari Ailus
2023-09-19 12:17 ` [PATCH v3 09/12] media: ov2740: Return -EPROBE_DEFER if no endpoint is found Sakari Ailus
2023-09-19 12:17 ` [PATCH v3 10/12] media: v4l: subdev: Clear frame descriptor before get_frame_desc Sakari Ailus
2023-09-19 12:17 ` [PATCH v3 11/12] media: v4l: subdev: Print debug information on frame descriptor Sakari Ailus
2023-09-19 13:32   ` Laurent Pinchart
2023-09-19 14:49     ` Sakari Ailus
2023-09-19 15:21       ` Laurent Pinchart
2023-09-22  9:41         ` Sakari Ailus
2023-09-22  9:53           ` Laurent Pinchart
2023-09-22 10:09             ` Sakari Ailus
2023-09-22 10:16               ` Tomi Valkeinen
2023-09-22 10:22                 ` Laurent Pinchart
2023-09-22 10:27                   ` Tomi Valkeinen
2023-09-22 14:51                     ` Laurent Pinchart
2023-09-22 10:23                 ` Sakari Ailus
2023-09-19 12:17 ` [PATCH v3 12/12] media: mc: Check pad flag validity Sakari Ailus
2023-09-19 13:26   ` Laurent Pinchart [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230919132657.GC1505@pendragon.ideasonboard.com \
    --to=laurent.pinchart@ideasonboard.com \
    --cc=bingbu.cao@intel.com \
    --cc=jacopo+renesas@jmondi.org \
    --cc=linux-media@vger.kernel.org \
    --cc=martink@posteo.de \
    --cc=rmfrfs@gmail.com \
    --cc=sakari.ailus@linux.intel.com \
    --cc=tian.shu.qiu@intel.com \
    --cc=tomi.valkeinen@ideasonboard.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.