Skip to content

Commit

Permalink
[PATCH] intelfb: Fix freeing of nonexistent resource
Browse files Browse the repository at this point in the history
Fix intelfb trying to free a non-existent resource in its error path.

Signed-off-by: Antonino Daplas <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
adaplas authored and Linus Torvalds committed Dec 20, 2005
1 parent 6ee7fb7 commit 4b3760c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
5 changes: 5 additions & 0 deletions drivers/video/intelfb/intelfb.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@

/*** 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
Expand Down Expand Up @@ -257,6 +261,7 @@ struct intelfb_info {
int hwcursor;
int fixed_mode;
int ring_active;
int flag;

/* hw cursor */
int cursor_on;
Expand Down
9 changes: 7 additions & 2 deletions drivers/video/intelfb/intelfbdrv.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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)) {
Expand All @@ -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;

Expand Down

0 comments on commit 4b3760c

Please sign in to comment.