From a6cb9d8e99d421c105802a0609233a8b013d62fb Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Tue, 11 Nov 2003 21:49:18 +0000 Subject: [PATCH] - Disable AGP on ALI chipsets if aperture size is 0. - Fail in agp_alloc_gatt if the aperture size is 0 instead of panicing in contigmalloc. Reported by: Bjoern Fischer Reviewed by: jhb MFC after: 1 week --- sys/dev/agp/agp.c | 5 +++++ sys/dev/agp/agp_ali.c | 4 ++++ sys/pci/agp.c | 5 +++++ sys/pci/agp_ali.c | 4 ++++ 4 files changed, 18 insertions(+) diff --git a/sys/dev/agp/agp.c b/sys/dev/agp/agp.c index 7bf49b29c3c..e66445995d7 100644 --- a/sys/dev/agp/agp.c +++ b/sys/dev/agp/agp.c @@ -175,6 +175,11 @@ agp_alloc_gatt(device_t dev) "allocating GATT for aperture of size %dM\n", apsize / (1024*1024)); + if (entries == 0) { + device_printf(dev, "bad aperture size\n"); + return NULL; + } + gatt = malloc(sizeof(struct agp_gatt), M_AGP, M_NOWAIT); if (!gatt) return 0; diff --git a/sys/dev/agp/agp_ali.c b/sys/dev/agp/agp_ali.c index b9b2c1326f5..fc99574de70 100644 --- a/sys/dev/agp/agp_ali.c +++ b/sys/dev/agp/agp_ali.c @@ -102,6 +102,10 @@ agp_ali_attach(device_t dev) return error; sc->initial_aperture = AGP_GET_APERTURE(dev); + if (sc->initial_aperture == 0) { + device_printf(dev, "bad initial aperture size, disabling\n"); + return ENXIO; + } for (;;) { gatt = agp_alloc_gatt(dev); diff --git a/sys/pci/agp.c b/sys/pci/agp.c index 7bf49b29c3c..e66445995d7 100644 --- a/sys/pci/agp.c +++ b/sys/pci/agp.c @@ -175,6 +175,11 @@ agp_alloc_gatt(device_t dev) "allocating GATT for aperture of size %dM\n", apsize / (1024*1024)); + if (entries == 0) { + device_printf(dev, "bad aperture size\n"); + return NULL; + } + gatt = malloc(sizeof(struct agp_gatt), M_AGP, M_NOWAIT); if (!gatt) return 0; diff --git a/sys/pci/agp_ali.c b/sys/pci/agp_ali.c index b9b2c1326f5..fc99574de70 100644 --- a/sys/pci/agp_ali.c +++ b/sys/pci/agp_ali.c @@ -102,6 +102,10 @@ agp_ali_attach(device_t dev) return error; sc->initial_aperture = AGP_GET_APERTURE(dev); + if (sc->initial_aperture == 0) { + device_printf(dev, "bad initial aperture size, disabling\n"); + return ENXIO; + } for (;;) { gatt = agp_alloc_gatt(dev);