From a0d0fcd3bab765b4db25e04884fd8a342abb9c66 Mon Sep 17 00:00:00 2001 From: iLisa Wu Date: Mon, 20 Aug 2007 15:44:07 +0200 Subject: Fix crash with no valid mode in xorg.conf's modelist and empty Virtual If the resolution defined in xorg.conf failed to find a matching mode in the supported modelist, and no virtual desktop dimensions are defined the xorg.conf either, virtual X and Y dimension will be set to 0 which will cause Xserver crash. (Novell bugzilla #296856, closed) --- src/radeon_modes.c | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/radeon_modes.c b/src/radeon_modes.c index 1a639717..e1635e09 100644 --- a/src/radeon_modes.c +++ b/src/radeon_modes.c @@ -299,6 +299,8 @@ int RADEONValidateDDCModes(ScrnInfoPtr pScrn1, char **ppModeName, DisplayModePtr first = NULL; DisplayModePtr ddcModes = NULL; int count = 0; + int maxXRes = 0; + int maxYRes = 0; int i, width, height; ScrnInfoPtr pScrn = pScrn1; @@ -334,13 +336,13 @@ int RADEONValidateDDCModes(ScrnInfoPtr pScrn1, char **ppModeName, p->Flags |= RADEON_USE_RMX; } - maxVirtX = MAX(maxVirtX, p->HDisplay); - maxVirtY = MAX(maxVirtY, p->VDisplay); + maxXRes = maxVirtX = MAX(maxVirtX, p->HDisplay); + maxYRes = maxVirtY = MAX(maxVirtY, p->VDisplay); count++; last = p; } - + /* Match up modes that are specified in the XF86Config file */ if (ppModeName[0]) { DisplayModePtr next; @@ -378,9 +380,21 @@ int RADEONValidateDDCModes(ScrnInfoPtr pScrn1, char **ppModeName, break; } } + if (!p) { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + " %dx%d is not supported by the device\n", + width, height); + } } } - + /* just for sanity check, if maxVirtX and maxVirtY are not + * specified, set max resolution that panel support for the max + * virtual dimensions */ + if ((!maxVirtX) || (!maxVirtY)) { + maxVirtX = maxXRes; + maxVirtY = maxYRes; + } + /* * Add remaining DDC modes if they're smaller than the user * specified modes -- cgit v1.2.3