diff mbox series

[2/3] media: imx: imx7-media-csi: Fail on invalid type in VIDIOC_G_SELECTION

Message ID 20230316143829.499039-3-alexander.stein@ew.tq-group.com (mailing list archive)
State New, archived
Headers show
Series imx7-media-csi: small cleanup | expand

Commit Message

Alexander Stein March 16, 2023, 2:38 p.m. UTC
This device only supports video capture, so bail out if invalid
selection type is passed.

Signed-off-by: Alexander Stein <alexander.stein@ew.tq-group.com>
---
 drivers/media/platform/nxp/imx7-media-csi.c | 3 +++
 1 file changed, 3 insertions(+)

Comments

Laurent Pinchart March 17, 2023, 6:32 p.m. UTC | #1
Hi Alexander,

Thank you for the patch.

On Thu, Mar 16, 2023 at 03:38:28PM +0100, Alexander Stein wrote:
> This device only supports video capture, so bail out if invalid
> selection type is passed.
> 
> Signed-off-by: Alexander Stein <alexander.stein@ew.tq-group.com>

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

> ---
>  drivers/media/platform/nxp/imx7-media-csi.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/drivers/media/platform/nxp/imx7-media-csi.c b/drivers/media/platform/nxp/imx7-media-csi.c
> index 3e97b9f2ff69..389d7d88b341 100644
> --- a/drivers/media/platform/nxp/imx7-media-csi.c
> +++ b/drivers/media/platform/nxp/imx7-media-csi.c
> @@ -1214,6 +1214,9 @@ static int imx7_csi_video_g_selection(struct file *file, void *fh,
>  {
>  	struct imx7_csi *csi = video_drvdata(file);
>  
> +	if (s->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
> +		return -EINVAL;
> +
>  	switch (s->target) {
>  	case V4L2_SEL_TGT_COMPOSE:
>  	case V4L2_SEL_TGT_COMPOSE_DEFAULT:
Rui Miguel Silva March 17, 2023, 7:21 p.m. UTC | #2
Laurent Pinchart <laurent.pinchart@ideasonboard.com> writes:

> Hi Alexander,
>
> Thank you for the patch.
>
> On Thu, Mar 16, 2023 at 03:38:28PM +0100, Alexander Stein wrote:
>> This device only supports video capture, so bail out if invalid
>> selection type is passed.
>> 
>> Signed-off-by: Alexander Stein <alexander.stein@ew.tq-group.com>
>
> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Rui Miguel Silva <rmfrfs@gmail.com>

Cheers,
  Rui
>
>> ---
>>  drivers/media/platform/nxp/imx7-media-csi.c | 3 +++
>>  1 file changed, 3 insertions(+)
>> 
>> diff --git a/drivers/media/platform/nxp/imx7-media-csi.c b/drivers/media/platform/nxp/imx7-media-csi.c
>> index 3e97b9f2ff69..389d7d88b341 100644
>> --- a/drivers/media/platform/nxp/imx7-media-csi.c
>> +++ b/drivers/media/platform/nxp/imx7-media-csi.c
>> @@ -1214,6 +1214,9 @@ static int imx7_csi_video_g_selection(struct file *file, void *fh,
>>  {
>>  	struct imx7_csi *csi = video_drvdata(file);
>>  
>> +	if (s->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
>> +		return -EINVAL;
>> +
>>  	switch (s->target) {
>>  	case V4L2_SEL_TGT_COMPOSE:
>>  	case V4L2_SEL_TGT_COMPOSE_DEFAULT:
>
> -- 
> Regards,
>
> Laurent Pinchart
diff mbox series

Patch

diff --git a/drivers/media/platform/nxp/imx7-media-csi.c b/drivers/media/platform/nxp/imx7-media-csi.c
index 3e97b9f2ff69..389d7d88b341 100644
--- a/drivers/media/platform/nxp/imx7-media-csi.c
+++ b/drivers/media/platform/nxp/imx7-media-csi.c
@@ -1214,6 +1214,9 @@  static int imx7_csi_video_g_selection(struct file *file, void *fh,
 {
 	struct imx7_csi *csi = video_drvdata(file);
 
+	if (s->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
+		return -EINVAL;
+
 	switch (s->target) {
 	case V4L2_SEL_TGT_COMPOSE:
 	case V4L2_SEL_TGT_COMPOSE_DEFAULT: