On Sun, 2026-05-31 at 21:55 +0200, Alexander A. Klimov wrote:
> Don't just overwrite the original pointer passed to krealloc()
> with its return value without checking latter:
[]
> diff --git a/drivers/gpu/drm/vc4/vc4_validate_shaders.c 
> b/drivers/gpu/drm/vc4/vc4_validate_shaders.c
[]
> @@ -290,15 +290,16 @@ static bool require_uniform_address_uniform(struct 
> vc4_validated_shader_info *va
>  {
>       uint32_t o = validated_shader->num_uniform_addr_offsets;
>       uint32_t num_uniforms = validated_shader->uniforms_size / 4;
> +     u32 *offsets;
>  
> -     validated_shader->uniform_addr_offsets =
> -             krealloc(validated_shader->uniform_addr_offsets,
> -                      (o + 1) *
> -                      sizeof(*validated_shader->uniform_addr_offsets),
> -                      GFP_KERNEL);
> -     if (!validated_shader->uniform_addr_offsets)
> +     offsets = krealloc(validated_shader->uniform_addr_offsets,
> +                        (o + 1) *
> +                        sizeof(*validated_shader->uniform_addr_offsets),
> +                        GFP_KERNEL);

krealloc_array ?

> +     if (!offsets)
>               return false;
>  
> +     validated_shader->uniform_addr_offsets = offsets;
>       validated_shader->uniform_addr_offsets[o] = num_uniforms;
>       validated_shader->num_uniform_addr_offsets++;

Reply via email to