]> pilppa.com Git - linux-2.6-omap-h63xx.git/commitdiff
[PATCH] intelfb: Fix freeing of nonexistent resource
authorAntonino A. Daplas <adaplas@gmail.com>
Mon, 19 Dec 2005 07:11:40 +0000 (15:11 +0800)
committerLinus Torvalds <torvalds@g5.osdl.org>
Tue, 20 Dec 2005 17:27:15 +0000 (09:27 -0800)
Fix intelfb trying to free a non-existent resource in its error path.

Signed-off-by: Antonino Daplas <adaplas@pol.net>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
drivers/video/intelfb/intelfb.h
drivers/video/intelfb/intelfbdrv.c

index f077ca34fabad6ed156a256d76908d5bc24a687b..da29d007f215d33103f2c9ea641c333df6704774 100644 (file)
 
 /*** hw-related values ***/
 
+/* Resource Allocation */
+#define INTELFB_FB_ACQUIRED                 1
+#define INTELFB_MMIO_ACQUIRED               2
+
 /* PCI ids for supported devices */
 #define PCI_DEVICE_ID_INTEL_830M       0x3577
 #define PCI_DEVICE_ID_INTEL_845G       0x2562
@@ -257,6 +261,7 @@ struct intelfb_info {
        int hwcursor;
        int fixed_mode;
        int ring_active;
+       int flag;
 
        /* hw cursor */
        int cursor_on;
index 427689e584da4745efd130960fd5ff2ae62ecc46..ac8d6617095e5c170bab85fef5c747116f818e52 100644 (file)
@@ -473,9 +473,9 @@ cleanup(struct intelfb_info *dinfo)
        if (dinfo->aperture.virtual)
                iounmap((void __iomem *)dinfo->aperture.virtual);
 
-       if (dinfo->mmio_base_phys)
+       if (dinfo->flag & INTELFB_MMIO_ACQUIRED)
                release_mem_region(dinfo->mmio_base_phys, INTEL_REG_SIZE);
-       if (dinfo->aperture.physical)
+       if (dinfo->flag & INTELFB_FB_ACQUIRED)
                release_mem_region(dinfo->aperture.physical,
                                   dinfo->aperture.size);
        framebuffer_release(dinfo->info);
@@ -572,6 +572,9 @@ intelfb_pci_register(struct pci_dev *pdev, const struct pci_device_id *ent)
                cleanup(dinfo);
                return -ENODEV;
        }
+
+       dinfo->flag |= INTELFB_FB_ACQUIRED;
+
        if (!request_mem_region(dinfo->mmio_base_phys,
                                INTEL_REG_SIZE,
                                INTELFB_MODULE_NAME)) {
@@ -580,6 +583,8 @@ intelfb_pci_register(struct pci_dev *pdev, const struct pci_device_id *ent)
                return -ENODEV;
        }
 
+       dinfo->flag |= INTELFB_MMIO_ACQUIRED;
+
        /* Get the chipset info. */
        dinfo->pci_chipset = pdev->device;