Skip to content

Commit

Permalink
drm/cirrus: check alloc_apertures() success in cirrus_kick_out_firmwa…
Browse files Browse the repository at this point in the history
…re_fb()

Check for alloc_apertures() memory allocation failure, and propagate an
error code in case the allocation failed.

Signed-off-by: Tommi Rantala <tt.rantala@gmail.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
  • Loading branch information
Tommi Rantala authored and Dave Airlie committed Nov 20, 2012
1 parent 9192674 commit bfb82ff
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions drivers/gpu/drm/cirrus/cirrus_drv.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,15 @@ static DEFINE_PCI_DEVICE_TABLE(pciidlist) = {
};


static void cirrus_kick_out_firmware_fb(struct pci_dev *pdev)
static int cirrus_kick_out_firmware_fb(struct pci_dev *pdev)
{
struct apertures_struct *ap;
bool primary = false;

ap = alloc_apertures(1);
if (!ap)
return -ENOMEM;

ap->ranges[0].base = pci_resource_start(pdev, 0);
ap->ranges[0].size = pci_resource_len(pdev, 0);

Expand All @@ -49,12 +52,18 @@ static void cirrus_kick_out_firmware_fb(struct pci_dev *pdev)
#endif
remove_conflicting_framebuffers(ap, "cirrusdrmfb", primary);
kfree(ap);

return 0;
}

static int __devinit
cirrus_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
{
cirrus_kick_out_firmware_fb(pdev);
int ret;

ret = cirrus_kick_out_firmware_fb(pdev);
if (ret)
return ret;

return drm_get_pci_dev(pdev, ent, &driver);
}
Expand Down

0 comments on commit bfb82ff

Please sign in to comment.