diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2010-07-24 13:29:37 -0400 |
---|---|---|
committer | Eric Anholt <eric@anholt.net> | 2010-08-01 22:35:14 -0400 |
commit | 831cd4453598b2c8e193f077023910c6b0c39558 (patch) | |
tree | 242d8e619cf40f3f760f4a26b16e6344f3ca6cfc /drivers/char | |
parent | 2bd34f6ca86b5a5f9b749624f73310820e7a93fd (diff) |
agp/intel: Destroy the scatterlist on allocation failure
A side-effect of being able to use custom page allocations with the
sg_table is that it cannot reap the partially constructed scatterlist if
fails to allocate a page. So we need to call sg_free_table() ourselves
if sg_alloc_table() fails.
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc Dave Airlie <airlied@redhat.com>
Signed-off-by: Eric Anholt <eric@anholt.net>
Diffstat (limited to 'drivers/char')
-rw-r--r-- | drivers/char/agp/intel-gtt.c | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/drivers/char/agp/intel-gtt.c b/drivers/char/agp/intel-gtt.c index 0c6d0fe32a2..f804325a735 100644 --- a/drivers/char/agp/intel-gtt.c +++ b/drivers/char/agp/intel-gtt.c | |||
@@ -104,7 +104,7 @@ static int intel_agp_map_memory(struct agp_memory *mem) | |||
104 | DBG("try mapping %lu pages\n", (unsigned long)mem->page_count); | 104 | DBG("try mapping %lu pages\n", (unsigned long)mem->page_count); |
105 | 105 | ||
106 | if (sg_alloc_table(&st, mem->page_count, GFP_KERNEL)) | 106 | if (sg_alloc_table(&st, mem->page_count, GFP_KERNEL)) |
107 | return -ENOMEM; | 107 | goto err; |
108 | 108 | ||
109 | mem->sg_list = sg = st.sgl; | 109 | mem->sg_list = sg = st.sgl; |
110 | 110 | ||
@@ -113,11 +113,14 @@ static int intel_agp_map_memory(struct agp_memory *mem) | |||
113 | 113 | ||
114 | mem->num_sg = pci_map_sg(intel_private.pcidev, mem->sg_list, | 114 | mem->num_sg = pci_map_sg(intel_private.pcidev, mem->sg_list, |
115 | mem->page_count, PCI_DMA_BIDIRECTIONAL); | 115 | mem->page_count, PCI_DMA_BIDIRECTIONAL); |
116 | if (unlikely(!mem->num_sg)) { | 116 | if (unlikely(!mem->num_sg)) |
117 | intel_agp_free_sglist(mem); | 117 | goto err; |
118 | return -ENOMEM; | 118 | |
119 | } | ||
120 | return 0; | 119 | return 0; |
120 | |||
121 | err: | ||
122 | sg_free_table(&st); | ||
123 | return -ENOMEM; | ||
121 | } | 124 | } |
122 | 125 | ||
123 | static void intel_agp_unmap_memory(struct agp_memory *mem) | 126 | static void intel_agp_unmap_memory(struct agp_memory *mem) |