diff options
-rw-r--r-- | drivers/char/agp/intel-agp.c | 29 |
1 files changed, 15 insertions, 14 deletions
diff --git a/drivers/char/agp/intel-agp.c b/drivers/char/agp/intel-agp.c index 148d7e38fddf..b9d9886ff3c3 100644 --- a/drivers/char/agp/intel-agp.c +++ b/drivers/char/agp/intel-agp.c | |||
@@ -196,6 +196,18 @@ static void intel_agp_unmap_page(struct page *page, dma_addr_t dma) | |||
196 | PAGE_SIZE, PCI_DMA_BIDIRECTIONAL); | 196 | PAGE_SIZE, PCI_DMA_BIDIRECTIONAL); |
197 | } | 197 | } |
198 | 198 | ||
199 | static void intel_agp_free_sglist(struct agp_memory *mem) | ||
200 | { | ||
201 | |||
202 | if (mem->sg_vmalloc_flag) | ||
203 | vfree(mem->sg_list); | ||
204 | else | ||
205 | kfree(mem->sg_list); | ||
206 | mem->sg_vmalloc_flag = 0; | ||
207 | mem->sg_list = NULL; | ||
208 | mem->num_sg = 0; | ||
209 | } | ||
210 | |||
199 | static int intel_agp_map_memory(struct agp_memory *mem) | 211 | static int intel_agp_map_memory(struct agp_memory *mem) |
200 | { | 212 | { |
201 | struct scatterlist *sg; | 213 | struct scatterlist *sg; |
@@ -224,13 +236,8 @@ static int intel_agp_map_memory(struct agp_memory *mem) | |||
224 | 236 | ||
225 | mem->num_sg = pci_map_sg(intel_private.pcidev, mem->sg_list, | 237 | mem->num_sg = pci_map_sg(intel_private.pcidev, mem->sg_list, |
226 | mem->page_count, PCI_DMA_BIDIRECTIONAL); | 238 | mem->page_count, PCI_DMA_BIDIRECTIONAL); |
227 | if (!mem->num_sg) { | 239 | if (unlikely(!mem->num_sg)) { |
228 | if (mem->sg_vmalloc_flag) | 240 | intel_agp_free_sglist(mem); |
229 | vfree(mem->sg_list); | ||
230 | else | ||
231 | kfree(mem->sg_list); | ||
232 | mem->sg_list = NULL; | ||
233 | mem->sg_vmalloc_flag = 0; | ||
234 | return -ENOMEM; | 241 | return -ENOMEM; |
235 | } | 242 | } |
236 | return 0; | 243 | return 0; |
@@ -242,13 +249,7 @@ static void intel_agp_unmap_memory(struct agp_memory *mem) | |||
242 | 249 | ||
243 | pci_unmap_sg(intel_private.pcidev, mem->sg_list, | 250 | pci_unmap_sg(intel_private.pcidev, mem->sg_list, |
244 | mem->page_count, PCI_DMA_BIDIRECTIONAL); | 251 | mem->page_count, PCI_DMA_BIDIRECTIONAL); |
245 | if (mem->sg_vmalloc_flag) | 252 | intel_agp_free_sglist(mem); |
246 | vfree(mem->sg_list); | ||
247 | else | ||
248 | kfree(mem->sg_list); | ||
249 | mem->sg_vmalloc_flag = 0; | ||
250 | mem->sg_list = NULL; | ||
251 | mem->num_sg = 0; | ||
252 | } | 253 | } |
253 | 254 | ||
254 | static void intel_agp_insert_sg_entries(struct agp_memory *mem, | 255 | static void intel_agp_insert_sg_entries(struct agp_memory *mem, |