agp: balance ioremap checks
authorScott Thompson <postfail at hushmail.com>
Sat, 25 Aug 2007 08:14:00 +0000 (18:14 +1000)
committerDave Airlie <airlied@linux.ie>
Sat, 25 Aug 2007 08:14:00 +0000 (18:14 +1000)
patchset against 2.6.23-rc3.
corrects missing ioremap return checks and balancing on iounmap calls, integrated changes per list
recommendations on the original set of patches..

Signed-off-by: Scott Thompson <postfail <at> hushmail.com>
Signed-off-by: Dave Airlie <airlied@linux.ie>
drivers/char/agp/amd-k7-agp.c
drivers/char/agp/ati-agp.c
drivers/char/agp/hp-agp.c
drivers/char/agp/i460-agp.c
drivers/char/agp/intel-agp.c
drivers/char/agp/nvidia-agp.c

index df0ddf14b85cd3d695718beffae359b4581881f8..f60bca70d1fba99f91cb6573b93d56bd3bea120c 100644 (file)
@@ -223,6 +223,8 @@ static int amd_irongate_configure(void)
        pci_read_config_dword(agp_bridge->dev, AMD_MMBASE, &temp);
        temp = (temp & PCI_BASE_ADDRESS_MEM_MASK);
        amd_irongate_private.registers = (volatile u8 __iomem *) ioremap(temp, 4096);
+       if (!amd_irongate_private.registers)
+               return -ENOMEM;
 
        /* Write out the address of the gatt table */
        writel(agp_bridge->gatt_bus_addr, amd_irongate_private.registers+AMD_ATTBASE);
index da7513d7b4e7e9b190f8ff72f1314ae633f94662..2d46b713c8f2a9f7ee5e54a5180ede15f270c29c 100644 (file)
@@ -213,6 +213,9 @@ static int ati_configure(void)
        temp = (temp & 0xfffff000);
        ati_generic_private.registers = (volatile u8 __iomem *) ioremap(temp, 4096);
 
+       if (!ati_generic_private.registers)
+               return -ENOMEM;
+
        if (is_r200())
                pci_write_config_dword(agp_bridge->dev, ATI_RS100_IG_AGPMODE, 0x20000);
        else
index bcdb149c8179cec8beeb15fe22394428504c467b..313a133a1172fac20135a71af05f2e865eddf420 100644 (file)
@@ -221,6 +221,7 @@ hp_zx1_lba_init (u64 hpa)
        if (cap != PCI_CAP_ID_AGP) {
                printk(KERN_ERR PFX "Invalid capability ID 0x%02x at 0x%x\n",
                       cap, hp->lba_cap_offset);
+               iounmap(hp->lba_regs);
                return -ENODEV;
        }
 
index 53354bf83af76389ba56c09b2c9a047e87460dd7..75d2aca6353de9ce1bb1bd90acfca27eddc60688 100644 (file)
@@ -249,6 +249,10 @@ static int i460_create_gatt_table (struct agp_bridge_data *bridge)
        num_entries = A_SIZE_8(temp)->num_entries;
 
        i460.gatt = ioremap(INTEL_I460_ATTBASE, PAGE_SIZE << page_order);
+       if (!i460.gatt) {
+               printk(KERN_ERR PFX "ioremap failed\n");
+               return -ENOMEM;
+       }
 
        /* These are no good, the should be removed from the agp_bridge strucure... */
        agp_bridge->gatt_table_real = NULL;
index 294cdbf4d44d9ecabe43ab892f4ee53502956be1..2c9ca2c64628dd178ca6ae489e5d129e5139f119 100644 (file)
@@ -930,8 +930,10 @@ static int intel_i915_create_gatt_table(struct agp_bridge_data *bridge)
        temp &= 0xfff80000;
 
        intel_private.registers = ioremap(temp,128 * 4096);
-       if (!intel_private.registers)
+       if (!intel_private.registers) {
+               iounmap(intel_private.gtt);
                return -ENOMEM;
+       }
 
        temp = readl(intel_private.registers+I810_PGETBL_CTL) & 0xfffff000;
        global_cache_flush();   /* FIXME: ? */
@@ -985,13 +987,15 @@ static int intel_i965_create_gatt_table(struct agp_bridge_data *bridge)
        temp &= 0xfff00000;
        intel_private.gtt = ioremap((temp + (512 * 1024)) , 512 * 1024);
 
-       if (!intel_private.gtt)
-               return -ENOMEM;
+       if (!intel_private.gtt)
+               return -ENOMEM;
 
 
        intel_private.registers = ioremap(temp,128 * 4096);
-       if (!intel_private.registers)
-               return -ENOMEM;
+       if (!intel_private.registers) {
+               iounmap(intel_private.gtt);
+               return -ENOMEM;
+       }
 
        temp = readl(intel_private.registers+I810_PGETBL_CTL) & 0xfffff000;
        global_cache_flush();   /* FIXME: ? */
index 6cd7373dcdf4fbd2cb3969fc961c58ddbd6b31c4..225ed2a53d45515655073bee3fea84c3a12df3af 100644 (file)
@@ -157,6 +157,9 @@ static int nvidia_configure(void)
        nvidia_private.aperture =
                (volatile u32 __iomem *) ioremap(apbase, 33 * PAGE_SIZE);
 
+       if (!nvidia_private.aperture)
+               return -ENOMEM;
+
        return 0;
 }