[PATCH] video: zynqmp: Prevent use of uninitialised variables

Michal Simek michal.simek at amd.com
Thu Oct 2 09:26:03 CEST 2025



On 10/1/25 18:36, Andrew Goodbody wrote:
> The variables 'offset_matrix' and 'csc_matrix' will be used
> uninitialised if video->is_rgb is false. Correct the logic so the
> attempt to use uninitialised variables is not made. Also remove the use
> of these variables as they seem to serve no useful purpose just being
> aliases for arrays.
> 
> This issue was found by Smatch.
> 
> Signed-off-by: Andrew Goodbody <andrew.goodbody at linaro.org>
> ---
>   drivers/video/zynqmp/zynqmp_dpsub.c | 12 +++++-------
>   1 file changed, 5 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/video/zynqmp/zynqmp_dpsub.c b/drivers/video/zynqmp/zynqmp_dpsub.c
> index 52af23c3c83592af4442af4fa7e345b85dabd9d2..a0efd3393f5fe2c3a468caec4ad81deef18dbdbf 100644
> --- a/drivers/video/zynqmp/zynqmp_dpsub.c
> +++ b/drivers/video/zynqmp/zynqmp_dpsub.c
> @@ -240,7 +240,6 @@ static void avbuf_video_select(struct udevice *dev, enum av_buf_video_stream vid
>   static void config_gfx_pipeline(struct udevice *dev)
>   {
>   	struct zynqmp_dpsub_priv *dp_sub = dev_get_priv(dev);
> -	u16 *csc_matrix, *offset_matrix;
>   	u32 regval = 0, index = 0, *scaling_factors = NULL;
>   	u16 rgb_coeffs[] = { 0x1000, 0x0000, 0x0000,
>   			     0x0000, 0x1000, 0x0000,
> @@ -262,19 +261,18 @@ static void config_gfx_pipeline(struct udevice *dev)
>   								video->sampling_en;
>   	writel(regval, dp_sub->base_addr + AVBUF_V_BLEND_LAYER1_CONTROL);
>   
> -	if (video->is_rgb) {
> -		csc_matrix = rgb_coeffs;
> -		offset_matrix = rgb_offset;
> -	}
> +	if (!video->is_rgb)
> +		return;
> +
>   	/* Program Colorspace conversion coefficients */
>   	for (index = 9; index < 12; index++) {
> -		writel(offset_matrix[index - 9], dp_sub->base_addr +
> +		writel(rgb_offset[index - 9], dp_sub->base_addr +
>   		       AVBUF_V_BLEND_IN2CSC_COEFF0 + (index * 4));
>   	}
>   
>   	/* Program Colorspace conversion matrix */
>   	for (index = 0; index < 9; index++) {
> -		writel(csc_matrix[index], dp_sub->base_addr +
> +		writel(rgb_coeffs[index], dp_sub->base_addr +
>   		       AVBUF_V_BLEND_IN2CSC_COEFF0 + (index * 4));
>   	}
>   }
> 
> ---
> base-commit: b2d5e46c67002e46ac339ef549ea18cf5adfcd87
> change-id: 20251001-video_zynqmp-8822d6863aea
> 
> Best regards,

Applied.
M


More information about the U-Boot mailing list