[5/9] media: jpu: Do not zero reserved fields
diff mbox series

Message ID 20210111145445.28854-6-ribalda@chromium.org
State New, archived
Headers show
Series
  • media: staging/intel-ipu3 : Do not zero reserved fields
Related show

Commit Message

Ricardo Ribalda Jan. 11, 2021, 2:54 p.m. UTC
Core code already clears reserved fields of struct
v4l2_pix_format_mplane, check: 4e1e0eb0e074 ("media: v4l2-ioctl: Zero
v4l2_plane_pix_format reserved fields").

Cc: Mikhail Ulyanov <mikhail.ulyanov@cogentembedded.com>
Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
---
 drivers/media/platform/rcar_jpu.c | 5 -----
 1 file changed, 5 deletions(-)

Comments

Kieran Bingham Jan. 12, 2021, 11:07 a.m. UTC | #1
Hi Ricardo,

On 11/01/2021 14:54, Ricardo Ribalda wrote:
> Core code already clears reserved fields of struct
> v4l2_pix_format_mplane, check: 4e1e0eb0e074 ("media: v4l2-ioctl: Zero
> v4l2_plane_pix_format reserved fields").
> 
> Cc: Mikhail Ulyanov <mikhail.ulyanov@cogentembedded.com>
> Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
> ---
>  drivers/media/platform/rcar_jpu.c | 5 -----
>  1 file changed, 5 deletions(-)
> 
> diff --git a/drivers/media/platform/rcar_jpu.c b/drivers/media/platform/rcar_jpu.c
> index 9b99ff368698..2bddc957cb87 100644
> --- a/drivers/media/platform/rcar_jpu.c
> +++ b/drivers/media/platform/rcar_jpu.c

There's a memset(cap->reserved...) in jpu_querycap()

Is that also applicable and covered by the core?

Looking at v4l_querycap() it doesn't seem to be so:


Reviewed-by: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>

> @@ -793,7 +793,6 @@ static int __jpu_try_fmt(struct jpu_ctx *ctx, struct jpu_fmt **fmtinfo,
>  	pix->colorspace = fmt->colorspace;
>  	pix->field = V4L2_FIELD_NONE;
>  	pix->num_planes = fmt->num_planes;
> -	memset(pix->reserved, 0, sizeof(pix->reserved));
>  
>  	jpu_bound_align_image(&pix->width, JPU_WIDTH_MIN, JPU_WIDTH_MAX,
>  			      fmt->h_align, &pix->height, JPU_HEIGHT_MIN,
> @@ -808,8 +807,6 @@ static int __jpu_try_fmt(struct jpu_ctx *ctx, struct jpu_fmt **fmtinfo,
>  			pix->plane_fmt[0].sizeimage = JPU_JPEG_HDR_SIZE +
>  				(JPU_JPEG_MAX_BYTES_PER_PIXEL * w * h);
>  		pix->plane_fmt[0].bytesperline = 0;
> -		memset(pix->plane_fmt[0].reserved, 0,
> -		       sizeof(pix->plane_fmt[0].reserved));
>  	} else {
>  		unsigned int i, bpl = 0;
>  
> @@ -822,8 +819,6 @@ static int __jpu_try_fmt(struct jpu_ctx *ctx, struct jpu_fmt **fmtinfo,
>  		for (i = 0; i < pix->num_planes; ++i) {
>  			pix->plane_fmt[i].bytesperline = bpl;
>  			pix->plane_fmt[i].sizeimage = bpl * h * fmt->bpp[i] / 8;
> -			memset(pix->plane_fmt[i].reserved, 0,
> -			       sizeof(pix->plane_fmt[i].reserved));
>  		}
>  	}
>  
>
Hans Verkuil Jan. 21, 2021, 9:53 a.m. UTC | #2
On 12/01/2021 12:07, Kieran Bingham wrote:
> Hi Ricardo,
> 
> On 11/01/2021 14:54, Ricardo Ribalda wrote:
>> Core code already clears reserved fields of struct
>> v4l2_pix_format_mplane, check: 4e1e0eb0e074 ("media: v4l2-ioctl: Zero
>> v4l2_plane_pix_format reserved fields").
>>
>> Cc: Mikhail Ulyanov <mikhail.ulyanov@cogentembedded.com>
>> Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
>> ---
>>  drivers/media/platform/rcar_jpu.c | 5 -----
>>  1 file changed, 5 deletions(-)
>>
>> diff --git a/drivers/media/platform/rcar_jpu.c b/drivers/media/platform/rcar_jpu.c
>> index 9b99ff368698..2bddc957cb87 100644
>> --- a/drivers/media/platform/rcar_jpu.c
>> +++ b/drivers/media/platform/rcar_jpu.c
> 
> There's a memset(cap->reserved...) in jpu_querycap()
> 
> Is that also applicable and covered by the core?

Yes: VIDIOC_QUERYCAP is a read-only ioctl: the core will always zero
the struct in that case before handing it over to the driver.

This is something for a separate patch, though. There may well be
more drivers that do this for querycap.

Regards,

	Hans

> 
> Looking at v4l_querycap() it doesn't seem to be so:
> 
> 
> Reviewed-by: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>
> 
>> @@ -793,7 +793,6 @@ static int __jpu_try_fmt(struct jpu_ctx *ctx, struct jpu_fmt **fmtinfo,
>>  	pix->colorspace = fmt->colorspace;
>>  	pix->field = V4L2_FIELD_NONE;
>>  	pix->num_planes = fmt->num_planes;
>> -	memset(pix->reserved, 0, sizeof(pix->reserved));
>>  
>>  	jpu_bound_align_image(&pix->width, JPU_WIDTH_MIN, JPU_WIDTH_MAX,
>>  			      fmt->h_align, &pix->height, JPU_HEIGHT_MIN,
>> @@ -808,8 +807,6 @@ static int __jpu_try_fmt(struct jpu_ctx *ctx, struct jpu_fmt **fmtinfo,
>>  			pix->plane_fmt[0].sizeimage = JPU_JPEG_HDR_SIZE +
>>  				(JPU_JPEG_MAX_BYTES_PER_PIXEL * w * h);
>>  		pix->plane_fmt[0].bytesperline = 0;
>> -		memset(pix->plane_fmt[0].reserved, 0,
>> -		       sizeof(pix->plane_fmt[0].reserved));
>>  	} else {
>>  		unsigned int i, bpl = 0;
>>  
>> @@ -822,8 +819,6 @@ static int __jpu_try_fmt(struct jpu_ctx *ctx, struct jpu_fmt **fmtinfo,
>>  		for (i = 0; i < pix->num_planes; ++i) {
>>  			pix->plane_fmt[i].bytesperline = bpl;
>>  			pix->plane_fmt[i].sizeimage = bpl * h * fmt->bpp[i] / 8;
>> -			memset(pix->plane_fmt[i].reserved, 0,
>> -			       sizeof(pix->plane_fmt[i].reserved));
>>  		}
>>  	}
>>  
>>
>

Patch
diff mbox series

diff --git a/drivers/media/platform/rcar_jpu.c b/drivers/media/platform/rcar_jpu.c
index 9b99ff368698..2bddc957cb87 100644
--- a/drivers/media/platform/rcar_jpu.c
+++ b/drivers/media/platform/rcar_jpu.c
@@ -793,7 +793,6 @@  static int __jpu_try_fmt(struct jpu_ctx *ctx, struct jpu_fmt **fmtinfo,
 	pix->colorspace = fmt->colorspace;
 	pix->field = V4L2_FIELD_NONE;
 	pix->num_planes = fmt->num_planes;
-	memset(pix->reserved, 0, sizeof(pix->reserved));
 
 	jpu_bound_align_image(&pix->width, JPU_WIDTH_MIN, JPU_WIDTH_MAX,
 			      fmt->h_align, &pix->height, JPU_HEIGHT_MIN,
@@ -808,8 +807,6 @@  static int __jpu_try_fmt(struct jpu_ctx *ctx, struct jpu_fmt **fmtinfo,
 			pix->plane_fmt[0].sizeimage = JPU_JPEG_HDR_SIZE +
 				(JPU_JPEG_MAX_BYTES_PER_PIXEL * w * h);
 		pix->plane_fmt[0].bytesperline = 0;
-		memset(pix->plane_fmt[0].reserved, 0,
-		       sizeof(pix->plane_fmt[0].reserved));
 	} else {
 		unsigned int i, bpl = 0;
 
@@ -822,8 +819,6 @@  static int __jpu_try_fmt(struct jpu_ctx *ctx, struct jpu_fmt **fmtinfo,
 		for (i = 0; i < pix->num_planes; ++i) {
 			pix->plane_fmt[i].bytesperline = bpl;
 			pix->plane_fmt[i].sizeimage = bpl * h * fmt->bpp[i] / 8;
-			memset(pix->plane_fmt[i].reserved, 0,
-			       sizeof(pix->plane_fmt[i].reserved));
 		}
 	}