[PATCH xf86-video-ati] Fix uninitialized use of local variable pitch in radeon_setup_kernel_mem

Alex Deucher alexdeucher at gmail.com
Wed Sep 12 20:16:56 UTC 2018


On Wed, Sep 5, 2018 at 12:24 PM Michel Dänzer <michel at daenzer.net> wrote:
>
> From: Michel Dänzer <michel.daenzer at amd.com>
>
> Fixes server reset.
>
> Pointed out by clang:
>
> ../../src/radeon_kms.c:2721:9: warning: variable 'pitch' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized]
>     if (!info->front_buffer) {
>         ^~~~~~~~~~~~~~~~~~~
> ../../src/radeon_kms.c:2765:27: note: uninitialized use occurs here
>     pScrn->displayWidth = pitch / cpp;
>                           ^~~~~
> ../../src/radeon_kms.c:2721:5: note: remove the 'if' if its condition is always true
>     if (!info->front_buffer) {
>     ^~~~~~~~~~~~~~~~~~~~~~~~~
> ../../src/radeon_kms.c:2680:14: note: initialize the variable 'pitch' to silence this warning
>     int pitch;
>              ^
>               = 0
>
> Signed-off-by: Michel Dänzer <michel.daenzer at amd.com>

Reviewed-by: Alex Deucher <alexander.deucher at amd.com>

> ---
>  src/radeon_kms.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/src/radeon_kms.c b/src/radeon_kms.c
> index a24776811..ae69f3353 100644
> --- a/src/radeon_kms.c
> +++ b/src/radeon_kms.c
> @@ -2760,10 +2760,11 @@ static Bool radeon_setup_kernel_mem(ScreenPtr pScreen)
>             if (tiling_flags)
>                 radeon_bo_set_tiling(info->front_buffer->bo.radeon, tiling_flags, pitch);
>         }
> -    }
>
> -    pScrn->displayWidth = pitch / cpp;
> +       pScrn->displayWidth = pitch / cpp;
> +    }
>
> +    pitch = pScrn->displayWidth * cpp;
>      xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Front buffer size: %dK\n",
>                pitch * pScrn->virtualY / 1024);
>      radeon_kms_update_vram_limit(pScrn, pitch * pScrn->virtualY);
> --
> 2.19.0.rc1
>
> _______________________________________________
> amd-gfx mailing list
> amd-gfx at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/amd-gfx


More information about the amd-gfx mailing list