* [PATCH v2] v4l2-subdev: Return -EOPNOTSUPP for unsupported pad type in call_get_frame_desc()
@ 2024-10-07 12:38 Prabhakar
2024-10-07 18:16 ` Laurent Pinchart
0 siblings, 1 reply; 4+ messages in thread
From: Prabhakar @ 2024-10-07 12:38 UTC (permalink / raw)
To: Laurent Pinchart, Sakari Ailus, Mauro Carvalho Chehab,
Hans Verkuil
Cc: linux-media, linux-kernel, linux-renesas-soc, Prabhakar, Biju Das,
Fabrizio Castro, Lad Prabhakar
From: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
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 <sakari.ailus@linux.intel.com>
Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
---
v1->v2
- Added a check for CONFIG_MEDIA_CONTROLLER, as the `entity` member in
`struct v4l2_subdev` is only available when CONFIG_MEDIA_CONTROLLER
is enabled.
---
drivers/media/v4l2-core/v4l2-subdev.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/drivers/media/v4l2-core/v4l2-subdev.c b/drivers/media/v4l2-core/v4l2-subdev.c
index de9ac67574bb..446fbc3805c7 100644
--- a/drivers/media/v4l2-core/v4l2-subdev.c
+++ b/drivers/media/v4l2-core/v4l2-subdev.c
@@ -325,6 +325,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);
--
2.43.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH v2] v4l2-subdev: Return -EOPNOTSUPP for unsupported pad type in call_get_frame_desc()
2024-10-07 12:38 [PATCH v2] v4l2-subdev: Return -EOPNOTSUPP for unsupported pad type in call_get_frame_desc() Prabhakar
@ 2024-10-07 18:16 ` Laurent Pinchart
2024-10-09 6:01 ` Sakari Ailus
0 siblings, 1 reply; 4+ messages in thread
From: Laurent Pinchart @ 2024-10-07 18:16 UTC (permalink / raw)
To: Prabhakar
Cc: Sakari Ailus, Mauro Carvalho Chehab, Hans Verkuil, linux-media,
linux-kernel, linux-renesas-soc, Biju Das, Fabrizio Castro,
Lad Prabhakar
Hi Prabhakar,
Thank you for the patch.
On Mon, Oct 07, 2024 at 01:38:09PM +0100, Prabhakar wrote:
> From: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
>
> 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 <sakari.ailus@linux.intel.com>
> Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
> ---
> v1->v2
> - Added a check for CONFIG_MEDIA_CONTROLLER, as the `entity` member in
> `struct v4l2_subdev` is only available when CONFIG_MEDIA_CONTROLLER
> is enabled.
> ---
> drivers/media/v4l2-core/v4l2-subdev.c | 5 +++++
> 1 file changed, 5 insertions(+)
>
> diff --git a/drivers/media/v4l2-core/v4l2-subdev.c b/drivers/media/v4l2-core/v4l2-subdev.c
> index de9ac67574bb..446fbc3805c7 100644
> --- a/drivers/media/v4l2-core/v4l2-subdev.c
> +++ b/drivers/media/v4l2-core/v4l2-subdev.c
> @@ -325,6 +325,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))
As this should really not happen, I wonder if we shouldn't be more
vocal:
if (WARN_ON(!(sd->entity.pads[pad].flags & MEDIA_PAD_FL_SOURCE)))
Sakari, what do you think ? Either way,
Reviewed-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
> + return -EOPNOTSUPP;
> +#endif
> +
> memset(fd, 0, sizeof(*fd));
>
> ret = sd->ops->pad->get_frame_desc(sd, pad, fd);
--
Regards,
Laurent Pinchart
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v2] v4l2-subdev: Return -EOPNOTSUPP for unsupported pad type in call_get_frame_desc()
2024-10-07 18:16 ` Laurent Pinchart
@ 2024-10-09 6:01 ` Sakari Ailus
2024-10-09 14:57 ` Laurent Pinchart
0 siblings, 1 reply; 4+ messages in thread
From: Sakari Ailus @ 2024-10-09 6:01 UTC (permalink / raw)
To: Laurent Pinchart
Cc: Prabhakar, Mauro Carvalho Chehab, Hans Verkuil, linux-media,
linux-kernel, linux-renesas-soc, Biju Das, Fabrizio Castro,
Lad Prabhakar
Hi Laurent,
On Mon, Oct 07, 2024 at 09:16:54PM +0300, Laurent Pinchart wrote:
> Hi Prabhakar,
>
> Thank you for the patch.
>
> On Mon, Oct 07, 2024 at 01:38:09PM +0100, Prabhakar wrote:
> > From: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
> >
> > 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 <sakari.ailus@linux.intel.com>
> > Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
> > ---
> > v1->v2
> > - Added a check for CONFIG_MEDIA_CONTROLLER, as the `entity` member in
> > `struct v4l2_subdev` is only available when CONFIG_MEDIA_CONTROLLER
> > is enabled.
> > ---
> > drivers/media/v4l2-core/v4l2-subdev.c | 5 +++++
> > 1 file changed, 5 insertions(+)
> >
> > diff --git a/drivers/media/v4l2-core/v4l2-subdev.c b/drivers/media/v4l2-core/v4l2-subdev.c
> > index de9ac67574bb..446fbc3805c7 100644
> > --- a/drivers/media/v4l2-core/v4l2-subdev.c
> > +++ b/drivers/media/v4l2-core/v4l2-subdev.c
> > @@ -325,6 +325,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))
>
> As this should really not happen, I wonder if we shouldn't be more
> vocal:
>
> if (WARN_ON(!(sd->entity.pads[pad].flags & MEDIA_PAD_FL_SOURCE)))
>
> Sakari, what do you think ? Either way,
I wouldn't as this is probably going to be user-triggerable. The problem
shouldn't be too hard to find out either.
>
> Reviewed-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Thanks!
--
Kind regards,
Sakari Ailus
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v2] v4l2-subdev: Return -EOPNOTSUPP for unsupported pad type in call_get_frame_desc()
2024-10-09 6:01 ` Sakari Ailus
@ 2024-10-09 14:57 ` Laurent Pinchart
0 siblings, 0 replies; 4+ messages in thread
From: Laurent Pinchart @ 2024-10-09 14:57 UTC (permalink / raw)
To: Sakari Ailus
Cc: Prabhakar, Mauro Carvalho Chehab, Hans Verkuil, linux-media,
linux-kernel, linux-renesas-soc, Biju Das, Fabrizio Castro,
Lad Prabhakar
On Wed, Oct 09, 2024 at 06:01:45AM +0000, Sakari Ailus wrote:
> Hi Laurent,
>
> On Mon, Oct 07, 2024 at 09:16:54PM +0300, Laurent Pinchart wrote:
> > Hi Prabhakar,
> >
> > Thank you for the patch.
> >
> > On Mon, Oct 07, 2024 at 01:38:09PM +0100, Prabhakar wrote:
> > > From: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
> > >
> > > 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 <sakari.ailus@linux.intel.com>
> > > Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
> > > ---
> > > v1->v2
> > > - Added a check for CONFIG_MEDIA_CONTROLLER, as the `entity` member in
> > > `struct v4l2_subdev` is only available when CONFIG_MEDIA_CONTROLLER
> > > is enabled.
> > > ---
> > > drivers/media/v4l2-core/v4l2-subdev.c | 5 +++++
> > > 1 file changed, 5 insertions(+)
> > >
> > > diff --git a/drivers/media/v4l2-core/v4l2-subdev.c b/drivers/media/v4l2-core/v4l2-subdev.c
> > > index de9ac67574bb..446fbc3805c7 100644
> > > --- a/drivers/media/v4l2-core/v4l2-subdev.c
> > > +++ b/drivers/media/v4l2-core/v4l2-subdev.c
> > > @@ -325,6 +325,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))
> >
> > As this should really not happen, I wonder if we shouldn't be more
> > vocal:
> >
> > if (WARN_ON(!(sd->entity.pads[pad].flags & MEDIA_PAD_FL_SOURCE)))
> >
> > Sakari, what do you think ? Either way,
>
> I wouldn't as this is probably going to be user-triggerable. The problem
> shouldn't be too hard to find out either.
I don't expect .get_frame_desc() to be callable with user-controllable
arguments, but I'm OK not using WARN_ON().
> > Reviewed-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
>
> Thanks!
--
Regards,
Laurent Pinchart
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2024-10-09 14:57 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-07 12:38 [PATCH v2] v4l2-subdev: Return -EOPNOTSUPP for unsupported pad type in call_get_frame_desc() Prabhakar
2024-10-07 18:16 ` Laurent Pinchart
2024-10-09 6:01 ` Sakari Ailus
2024-10-09 14:57 ` Laurent Pinchart
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox