diff options
author | Tommi Rantala <tt.rantala@gmail.com> | 2012-11-09 04:19:35 -0500 |
---|---|---|
committer | Dave Airlie <airlied@redhat.com> | 2012-11-20 01:06:23 -0500 |
commit | bfb82ff0ee1dd0d1eed45ee25aa601f4ea5c54ac (patch) | |
tree | 9501354b485d137f8c58b4fb27f88dea9c3939f9 | |
parent | 91926741ecd28dc246875a39a908c2f6aadb2542 (diff) |
drm/cirrus: check alloc_apertures() success in cirrus_kick_out_firmware_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>
-rw-r--r-- | drivers/gpu/drm/cirrus/cirrus_drv.c | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/drivers/gpu/drm/cirrus/cirrus_drv.c b/drivers/gpu/drm/cirrus/cirrus_drv.c index 101e423c8991..dcd1a8c029eb 100644 --- a/drivers/gpu/drm/cirrus/cirrus_drv.c +++ b/drivers/gpu/drm/cirrus/cirrus_drv.c | |||
@@ -35,12 +35,15 @@ static DEFINE_PCI_DEVICE_TABLE(pciidlist) = { | |||
35 | }; | 35 | }; |
36 | 36 | ||
37 | 37 | ||
38 | static void cirrus_kick_out_firmware_fb(struct pci_dev *pdev) | 38 | static int cirrus_kick_out_firmware_fb(struct pci_dev *pdev) |
39 | { | 39 | { |
40 | struct apertures_struct *ap; | 40 | struct apertures_struct *ap; |
41 | bool primary = false; | 41 | bool primary = false; |
42 | 42 | ||
43 | ap = alloc_apertures(1); | 43 | ap = alloc_apertures(1); |
44 | if (!ap) | ||
45 | return -ENOMEM; | ||
46 | |||
44 | ap->ranges[0].base = pci_resource_start(pdev, 0); | 47 | ap->ranges[0].base = pci_resource_start(pdev, 0); |
45 | ap->ranges[0].size = pci_resource_len(pdev, 0); | 48 | ap->ranges[0].size = pci_resource_len(pdev, 0); |
46 | 49 | ||
@@ -49,12 +52,18 @@ static void cirrus_kick_out_firmware_fb(struct pci_dev *pdev) | |||
49 | #endif | 52 | #endif |
50 | remove_conflicting_framebuffers(ap, "cirrusdrmfb", primary); | 53 | remove_conflicting_framebuffers(ap, "cirrusdrmfb", primary); |
51 | kfree(ap); | 54 | kfree(ap); |
55 | |||
56 | return 0; | ||
52 | } | 57 | } |
53 | 58 | ||
54 | static int __devinit | 59 | static int __devinit |
55 | cirrus_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) | 60 | cirrus_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) |
56 | { | 61 | { |
57 | cirrus_kick_out_firmware_fb(pdev); | 62 | int ret; |
63 | |||
64 | ret = cirrus_kick_out_firmware_fb(pdev); | ||
65 | if (ret) | ||
66 | return ret; | ||
58 | 67 | ||
59 | return drm_get_pci_dev(pdev, ent, &driver); | 68 | return drm_get_pci_dev(pdev, ent, &driver); |
60 | } | 69 | } |