[RESEND] xfree86: prune duplicate monitor modes.

Hans de Goede hdegoede at redhat.com
Thu Sep 1 14:19:27 UTC 2016


Hi,

On 11-12-15 08:43, Michel Dänzer wrote:
> From: Leo Liu <leo.liu at amd.com>
>
> same monitor modes added causing memory leak
> when looping `xrandr --prop'.
>
> Signed-off-by: Leo Liu <leo.liu at amd.com>
> Signed-off-by: Michel Dänzer <michel.daenzer at amd.com>
> ---
>
> More than two years later... Can somebody pick this up?

And almost another year later. I've been going over
patches stuck in patchwork today and this one stood out,
I believe the problem is still valid, correct ?

The fix could be better though, we already have:

xf86PruneDuplicateModes()

So IMHO the right fix would be to:

1) Append new modes to the monitor modes
2) Call xf86PruneDuplicateModes()
3) Search for Last mode and update Monitor->Last

Without introducing a new unneeded helper function.

Regards,

Hans




>
>  hw/xfree86/modes/xf86EdidModes.c |   22 ++++++++++++++++++++++
>  1 file changed, 22 insertions(+)
>
>  }
>
> diff --git a/hw/xfree86/modes/xf86EdidModes.c
> b/hw/xfree86/modes/xf86EdidModes.c
> index 4ee862d..261780b 100644
> --- a/hw/xfree86/modes/xf86EdidModes.c
> +++ b/hw/xfree86/modes/xf86EdidModes.c
> @@ -1143,6 +1143,27 @@ handle_detailed_monset(struct
> detailed_monitor_section *det_mon, void *data)
>      }
>  }
>  +static void
> +xf86PruneDuplicateMonitorModes(MonPtr Monitor)
> +{
> +    DisplayModePtr master, clone, next;
> +
> +    for (master = Monitor->Modes;
> +         master && master != Monitor->Last;
> +         master = master->next) {
> +        for (clone = master->next;
> +             clone && clone != Monitor->Modes;
> +             clone = next) {
> +            next = clone->next;
> +            if (xf86ModesEqual (master, clone)) {
> +                if (Monitor->Last == clone)
> +                    Monitor->Last = clone->prev;
> +                xf86DeleteMode (&Monitor->Modes, clone);
> +            }
> +        }
> +    }
> +}
> +
>  /*
>   * Fill out MonPtr with xf86MonPtr information.
>   */
> @@ -1204,5 +1225,6 @@ xf86EdidMonitorSet(int scrnIndex, MonPtr Monitor,
> xf86MonPtr DDC)
>              Monitor->Modes = Modes;
>              Monitor->Last = Mode;
>          }
> +        xf86PruneDuplicateMonitorModes(Monitor);
>      }
>


More information about the xorg-devel mailing list