[PATCH] xf86Crtc: handle no outputs with no modes harder.

Alex Deucher alexdeucher at gmail.com
Thu Oct 20 07:33:40 PDT 2011


On Thu, Oct 20, 2011 at 9:43 AM, Dave Airlie <airlied at gmail.com> wrote:
> From: Dave Airlie <airlied at redhat.com>
>
> If you started an X server with no connected outputs, we pick a default
> 1024x768 mode, however if you then ran an xvidmode using app against that
> server it would segfault the server due to not finding any valid modes.
>
> This was due to the no output mode set code, only adding the modes to the
> scrn->modes once, when something called randr 1.2 xf86SetScrnInfoModes would
> get called and remove all the modes and we'd end up with 0.
>
> This change fixes xf86SetScrnInfoModes to always report a scrn mode of at
> least 1024x768, and pushes the initial configuration to just call it instead
> of setting up the mode itself.
>
> Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=746926
>
> I've seen other bugs like this on other distros so it might also actually fix them.
>
> Signed-off-by: Dave Airlie <airlied at redhat.com>

Seems reasonable to me.

Reviewed-by: Alex Deucher <alexander.deucher at amd.com>

> ---
>  hw/xfree86/modes/xf86Crtc.c |   41 +++++++++++++++++++----------------------
>  1 files changed, 19 insertions(+), 22 deletions(-)
>
> diff --git a/hw/xfree86/modes/xf86Crtc.c b/hw/xfree86/modes/xf86Crtc.c
> index cbe0b5c..fc34a6b 100644
> --- a/hw/xfree86/modes/xf86Crtc.c
> +++ b/hw/xfree86/modes/xf86Crtc.c
> @@ -1915,19 +1915,25 @@ xf86SetScrnInfoModes (ScrnInfoPtr scrn)
>                break;
>     }
>
> -    if (scrn->modes != NULL) {
> -       /* For some reason, scrn->modes is circular, unlike the other mode
> -        * lists.  How great is that?
> -        */
> -       for (last = scrn->modes; last && last->next; last = last->next)
> -           ;
> -       last->next = scrn->modes;
> -       scrn->modes->prev = last;
> -       if (mode) {
> -           while (scrn->modes != mode)
> -               scrn->modes = scrn->modes->next;
> -       }
> +    if (!scrn->modes) {
> +       scrn->modes = xf86ModesAdd(scrn->modes,
> +                                  xf86CVTMode(scrn->display->virtualX,
> +                                              scrn->display->virtualY,
> +                                              60, 0, 0));
> +    }
> +
> +    /* For some reason, scrn->modes is circular, unlike the other mode
> +     * lists.  How great is that?
> +     */
> +    for (last = scrn->modes; last && last->next; last = last->next)
> +       ;
> +    last->next = scrn->modes;
> +    scrn->modes->prev = last;
> +    if (mode) {
> +       while (scrn->modes != mode)
> +           scrn->modes = scrn->modes->next;
>     }
> +
>     scrn->currentMode = scrn->modes;
>  #ifdef XFreeXDGA
>     if (scrn->pScreen)
> @@ -2514,16 +2520,7 @@ xf86InitialConfiguration (ScrnInfoPtr scrn, Bool canGrow)
>                              width, height);
>     }
>
> -    if (have_outputs) {
> -       /* Mirror output modes to scrn mode list */
> -       xf86SetScrnInfoModes (scrn);
> -    } else {
> -       /* Clear any existing modes from scrn->modes */
> -       while (scrn->modes != NULL)
> -           xf86DeleteMode(&scrn->modes, scrn->modes);
> -       scrn->modes = xf86ModesAdd(scrn->modes,
> -                                  xf86CVTMode(width, height, 60, 0, 0));
> -    }
> +    xf86SetScrnInfoModes (scrn);
>
>     success = TRUE;
>  bailout:
> --
> 1.7.6.4
>
> _______________________________________________
> xorg-devel at lists.x.org: X.Org development
> Archives: http://lists.x.org/archives/xorg-devel
> Info: http://lists.x.org/mailman/listinfo/xorg-devel
>


More information about the xorg-devel mailing list