[v4 2/3] lib/igt_draw: Sanitize the buffer data in the beginning

Zbigniew Kempczyński zbigniew.kempczynski at intel.com
Wed Mar 27 04:59:51 UTC 2024


On Tue, Mar 26, 2024 at 07:44:21PM +0530, Vandita Kulkarni wrote:
> Since now we have a new member in buffer data which is a
> pointer, we need to initialise the buf_ptr. If left uninitialised
> may contain garbage. Also may be used in wc write method if it is
> initialised to already mmapped buffer.
> 
> Signed-off-by: Vandita Kulkarni <vandita.kulkarni at intel.com>
> ---
>  lib/igt_draw.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/lib/igt_draw.c b/lib/igt_draw.c
> index a4d5f2f0e..5ad631f38 100644
> --- a/lib/igt_draw.c
> +++ b/lib/igt_draw.c
> @@ -801,7 +801,7 @@ static void draw_rect_render(int fd, struct cmd_data *cmd_data,
>  	uint32_t devid = intel_get_drm_devid(fd);
>  	igt_render_copyfunc_t rendercopy = igt_get_render_copyfunc(devid);
>  	struct intel_bb *ibb;
> -	struct buf_data tmp;
> +	struct buf_data tmp = {};
>  	int pixel_size = buf->bpp / 8;
>  
>  	igt_skip_on(!rendercopy);
> @@ -822,6 +822,7 @@ static void draw_rect_render(int fd, struct cmd_data *cmd_data,
>  	tmp.bpp = buf->bpp;
>  	tmp.width = rect->w;
>  	tmp.height = rect->h;
> +	tmp.buf_ptr = buf->buf_ptr;
>  	if (is_i915_device(fd))
>  		draw_rect_mmap_cpu(fd, &tmp, &(struct rect){0, 0, rect->w, rect->h},
>  				   I915_TILING_NONE, I915_BIT_6_SWIZZLE_NONE, color);
> -- 
> 2.43.2
> 

LGTM.

Reviewed-by: Zbigniew Kempczyński <zbigniew.kempczynski at intel.com>

--
Zbigniew


More information about the igt-dev mailing list