xf86-video-amdgpu: Branch 'master' - 2 commits

Michel Dänzer daenzer at kemper.freedesktop.org
Wed Oct 7 01:07:31 PDT 2015


 src/drmmode_display.c |   20 +++++++++++---------
 1 file changed, 11 insertions(+), 9 deletions(-)

New commits:
commit 460560502a1bdf26d06f3c30df46fa9f28ffb9e5
Author: Tom St Denis <tom.stdenis at amd.com>
Date:   Tue Oct 6 08:49:54 2015 -0400

    Simplify drmmode_set_mode_major() and avoid leaking memory.
    
    The function would leak the memory allocated for output_ids.  This
    patch addresses that as well as simplifies the logic somewhat.
    
    Signed-off-by: Tom St Denis <tom.stdenis at amd.com>
    Reviewed-by: Michel Dänzer <michel.daenzer at amd.com>

diff --git a/src/drmmode_display.c b/src/drmmode_display.c
index a91d018..b1a485d 100644
--- a/src/drmmode_display.c
+++ b/src/drmmode_display.c
@@ -577,7 +577,7 @@ drmmode_set_mode_major(xf86CrtcPtr crtc, DisplayModePtr mode,
 	int saved_x, saved_y;
 	Rotation saved_rotation;
 	DisplayModeRec saved_mode;
-	uint32_t *output_ids;
+	uint32_t *output_ids = NULL;
 	int output_count = 0;
 	Bool ret = TRUE;
 	int i;
@@ -614,15 +614,13 @@ drmmode_set_mode_major(xf86CrtcPtr crtc, DisplayModePtr mode,
 		crtc->y = y;
 		crtc->rotation = rotation;
 		crtc->transformPresent = FALSE;
-	}
 
-	output_ids = calloc(sizeof(uint32_t), xf86_config->num_output);
-	if (!output_ids) {
-		ret = FALSE;
-		goto done;
-	}
+		output_ids = calloc(sizeof(uint32_t), xf86_config->num_output);
+		if (!output_ids) {
+			ret = FALSE;
+			goto done;
+		}
 
-	if (mode) {
 		ScreenPtr pScreen = pScrn->pScreen;
 
 		for (i = 0; i < xf86_config->num_output; i++) {
@@ -734,6 +732,7 @@ drmmode_set_mode_major(xf86CrtcPtr crtc, DisplayModePtr mode,
 		xf86_reload_cursors(pScrn->pScreen);
 
 done:
+	free(output_ids);
 	if (!ret) {
 		crtc->x = saved_x;
 		crtc->y = saved_y;
commit 56398d6651dfc4935cbd117ad861e1800077c73c
Author: Tom St Denis <tom.stdenis at amd.com>
Date:   Tue Oct 6 08:43:12 2015 -0400

    Avoid NULL dereference if drmmode_crtc_scanout_allocate fails
    
    This avoids a NULL dereference if the memory allocation fails.
    
    Signed-off-by: Tom St Denis <tom.stdenis at amd.com>
    Reviewed-by: Michel Dänzer <michel.daenzer at amd.com>

diff --git a/src/drmmode_display.c b/src/drmmode_display.c
index d75a629..a91d018 100644
--- a/src/drmmode_display.c
+++ b/src/drmmode_display.c
@@ -535,8 +535,11 @@ drmmode_crtc_scanout_create(xf86CrtcPtr crtc,
 		drmmode_crtc_scanout_destroy(drmmode, scanout);
 	}
 
-	if (!data)
+	if (!data) {
 		data = drmmode_crtc_scanout_allocate(crtc, scanout, width, height);
+		if (!data)
+			return NULL;
+	}
 
 	rotate_pitch = gbm_bo_get_stride(scanout->bo->bo.gbm);
 


More information about the xorg-commit mailing list