[PATCH 2/7] radeontool: error out for missing control or fb region

Jonathan Nieder jrnieder at gmail.com
Tue Mar 23 19:52:19 PDT 2010


Do not blithely use an uninitialized value when the expected
memory areas cannot be found.

This is triggered by trying to use radeontool on an r128.

Noticed-by: Tormod Volden <debian.tormod at gmail.com>
Signed-off-by: Jonathan Nieder <jrnieder at gmail.com>
Acked-by: Tormod Volden <debian.tormod at gmail.com>
---
 radeontool.c |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/radeontool.c b/radeontool.c
index ab5c76e..7fd1010 100644
--- a/radeontool.c
+++ b/radeontool.c
@@ -33,7 +33,7 @@ int skip = 0;
 /* Not the address but what it points to is volatile. */
 struct pci_device *avivo_device = NULL;
 unsigned char * volatile radeon_cntl_mem;
-unsigned int ctrl_region, fb_region;
+int ctrl_region = -1, fb_region = -1;
 unsigned char * volatile fb_mem;
 unsigned char * volatile ctrl_mem;
 static void radeon_rom_legacy_mmio_table(unsigned char *bios, int offset);
@@ -882,7 +882,7 @@ void radeon_cmd_stretch(char *param)
 }
 
 
-/* Here we fork() and exec() the lspci command to look for the Radeon hardware address. */
+/* Look for the Radeon hardware address. */
 static void map_radeon_cntl_mem(void)
 {
     struct pci_slot_match match;
@@ -919,6 +919,10 @@ static void map_radeon_cntl_mem(void)
                 else if (device->regions[i].size >= 128 * 1024 * 1024)
                     fb_region = i;
             }
+            if (ctrl_region == -1)
+                fatal("cannot find ctrl region\n");
+            if (fb_region == -1)
+                fatal("cannot find fb region\n");
             avivo_device = device;
             break;
         }
-- 
1.7.0.3



More information about the xorg-driver-ati mailing list