[PATCH RESEND] xfree86: prune duplicate monitor modes.

Eric Anholt eric at anholt.net
Wed Jan 27 17:46:01 PST 2016


Michel Dänzer <michel at daenzer.net> writes:

> 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?
>
>  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);
>      }
>  }

It looks like xf86EdidMonitorSet() is just appending the new DDC modes
to the monitor.  If you switch monitors, I think you get the DDC modes
From both.  Shouldn't we just be deleting the old M_T_DRIVER modes right
before appending?
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 818 bytes
Desc: not available
URL: <http://lists.x.org/archives/xorg-devel/attachments/20160127/2c2688a7/attachment.sig>


More information about the xorg-devel mailing list