Module Name:    xsrc
Committed By:   ahoka
Date:           Sun Jun 21 20:42:30 UTC 2009

Modified Files:
        xsrc/external/mit/xf86-video-s3/dist/src: s3_bios.c

Log Message:
Do better error checking around libpciaccess, like the intel driver does.
This makes the driver working again after the last Xorg update.

Although this doesn't really fix the real issue, but makes the driver more
robust, thus it reports the error in the logfile instead of dumping core.

This should go to upstream.


To generate a diff of this commit:
cvs rdiff -u -r1.1.1.2 -r1.2 \
    xsrc/external/mit/xf86-video-s3/dist/src/s3_bios.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: xsrc/external/mit/xf86-video-s3/dist/src/s3_bios.c
diff -u xsrc/external/mit/xf86-video-s3/dist/src/s3_bios.c:1.1.1.2 xsrc/external/mit/xf86-video-s3/dist/src/s3_bios.c:1.2
--- xsrc/external/mit/xf86-video-s3/dist/src/s3_bios.c:1.1.1.2	Fri Jun  5 20:58:36 2009
+++ xsrc/external/mit/xf86-video-s3/dist/src/s3_bios.c	Sun Jun 21 20:42:29 2009
@@ -36,27 +36,38 @@
 #include "s3.h"
 
 
-static unsigned char *find_bios_string(S3Ptr pS3, int BIOSbase,
+static unsigned char *find_bios_string(ScrnInfoPtr pScrn, int BIOSbase,
 				       char *match1, char *match2)
 {
-	static unsigned char bios[BIOS_BSIZE];
+	static unsigned char *bios;
 	static int init=0;
-	int i, j, l1, l2;
+	int i, j, l1, l2, ret;
+
+	S3Ptr pS3 = S3PTR(pScrn);
+
+	bios = xalloc(BIOS_BSIZE);
+	if (bios = NULL)
+		return NULL;
 
 	if (!init) {
 		init = 1;
 #ifndef XSERVER_LIBPCIACCESS
 		if (xf86ReadDomainMemory(pS3->PciTag, BIOSbase, BIOS_BSIZE, bios) != BIOS_BSIZE)
-			return NULL;
+			goto error;
 #else
-		if (pci_device_read_rom(pS3->PciInfo, bios))
-		        return NULL;
+		ret = pci_device_read_rom(pS3->PciInfo, bios);
+		if (ret) {
+			xf86DrvMsg(pScrn->scrnIndex, X_WARNING,
+				"libpciaccess failed to read video BIOS: %s\n",
+				strerror(-ret));
+		        goto error;
+		}
 #endif
 		if ((bios[0] != 0x55) || (bios[1] != 0xaa))
-			return NULL;
+			goto error;
 	}
 	if (match1 == NULL)
-		return NULL;
+		goto error;
 
 	l1 = strlen(match1);
 	if (match2 != NULL)
@@ -74,17 +85,17 @@
 					    !memcmp(&bios[j], match2, l2))
 						return &bios[j+l2];
 		}
-
+error:
+	xfree(bios);
 	return NULL;
 }
 
 
 int S3GetRefClock(ScrnInfoPtr pScrn)
 {
-	S3Ptr pS3 = S3PTR(pScrn);
 	int RefClock = 16000;	/* default */
 
-	if (find_bios_string(pS3, BIOS_BASE, "Number Nine Visual Technology",
+	if (find_bios_string(pScrn, BIOS_BASE, "Number Nine Visual Technology",
 					"Motion 771") != NULL)
 		RefClock = 16000;
 

Reply via email to