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

Michel Dänzer michel at daenzer.net
Wed Sep 5 16:24:06 UTC 2018


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>
---
 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



More information about the amd-gfx mailing list