diff options
| author | Adam Hoka <ahoka@NetBSD.org> | 2009-07-05 22:01:46 +0200 |
|---|---|---|
| committer | Charlie <root@hitchhiker.vnode.ch> | 2009-07-05 22:01:46 +0200 |
| commit | c41a1188ce53b8975e6d5c34c54a77a3f3c291bc (patch) | |
| tree | 4a66f43d0e70f96dfb627bf6cbde403bca2cf759 | |
| parent | aa955eda7b6fddd12b163ee66367ecc998f82ae0 (diff) | |
Handle libpciaccess errors more gently and report any problems
encountered in Xorg.log (server crash versus log entry).
This fixes PR 22510. Report and fix by Adam Hoka <ahoka@NetBSD.org>,
many thanks.
Reviewed-by: Matthieu Herrb <herrb@laas.fr>
Signed-off-by: Marc Balmer <marc@msys.ch>
| -rw-r--r-- | src/s3_bios.c | 33 |
1 files changed, 22 insertions, 11 deletions
diff --git a/src/s3_bios.c b/src/s3_bios.c index 6fbf561..6ea9181 100644 --- a/src/s3_bios.c +++ b/src/s3_bios.c @@ -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 @@ static unsigned char *find_bios_string(S3Ptr pS3, int BIOSbase, !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; |
