Commit 46056050 authored by Tom Denis's avatar Tom Denis Committed by Michel Dänzer
Browse files

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 Denis's avatarTom St Denis <tom.stdenis@amd.com>
Reviewed-by: Michel Dänzer's avatarMichel Dänzer <michel.daenzer@amd.com>
parent 56398d66
...@@ -577,7 +577,7 @@ drmmode_set_mode_major(xf86CrtcPtr crtc, DisplayModePtr mode, ...@@ -577,7 +577,7 @@ drmmode_set_mode_major(xf86CrtcPtr crtc, DisplayModePtr mode,
int saved_x, saved_y; int saved_x, saved_y;
Rotation saved_rotation; Rotation saved_rotation;
DisplayModeRec saved_mode; DisplayModeRec saved_mode;
uint32_t *output_ids; uint32_t *output_ids = NULL;
int output_count = 0; int output_count = 0;
Bool ret = TRUE; Bool ret = TRUE;
int i; int i;
...@@ -614,15 +614,13 @@ drmmode_set_mode_major(xf86CrtcPtr crtc, DisplayModePtr mode, ...@@ -614,15 +614,13 @@ drmmode_set_mode_major(xf86CrtcPtr crtc, DisplayModePtr mode,
crtc->y = y; crtc->y = y;
crtc->rotation = rotation; crtc->rotation = rotation;
crtc->transformPresent = FALSE; crtc->transformPresent = FALSE;
}
output_ids = calloc(sizeof(uint32_t), xf86_config->num_output); output_ids = calloc(sizeof(uint32_t), xf86_config->num_output);
if (!output_ids) { if (!output_ids) {
ret = FALSE; ret = FALSE;
goto done; goto done;
} }
if (mode) {
ScreenPtr pScreen = pScrn->pScreen; ScreenPtr pScreen = pScrn->pScreen;
for (i = 0; i < xf86_config->num_output; i++) { for (i = 0; i < xf86_config->num_output; i++) {
...@@ -734,6 +732,7 @@ drmmode_set_mode_major(xf86CrtcPtr crtc, DisplayModePtr mode, ...@@ -734,6 +732,7 @@ drmmode_set_mode_major(xf86CrtcPtr crtc, DisplayModePtr mode,
xf86_reload_cursors(pScrn->pScreen); xf86_reload_cursors(pScrn->pScreen);
done: done:
free(output_ids);
if (!ret) { if (!ret) {
crtc->x = saved_x; crtc->x = saved_x;
crtc->y = saved_y; crtc->y = saved_y;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment