summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom St Denis <tom.stdenis@amd.com>2015-11-11 15:51:19 +0900
committerMichel Dänzer <michel@daenzer.net>2015-11-12 11:27:15 +0900
commit875ad48e7b5cdb7beefbf18dddcbee3ed22b5446 (patch)
tree96d545230f07c4fedfbdf4d6082f6144f1575598
parent789d7d6a04cca6b36fb088a074027807ccb8dd61 (diff)
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@amd.com> (ported from amdgpu commit 460560502a1bdf26d06f3c30df46fa9f28ffb9e5) Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
-rw-r--r--src/drmmode_display.c15
1 files changed, 7 insertions, 8 deletions
diff --git a/src/drmmode_display.c b/src/drmmode_display.c
index 3a3f407e..561b55ed 100644
--- a/src/drmmode_display.c
+++ b/src/drmmode_display.c
@@ -626,7 +626,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;
@@ -672,15 +672,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++) {
@@ -792,6 +790,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;