Commit 831cd445 authored by Chris Wilson's avatar Chris Wilson Committed by Eric Anholt

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: default avatarChris Wilson <chris@chris-wilson.co.uk>
Cc Dave Airlie <airlied@redhat.com>
Signed-off-by: default avatarEric Anholt <eric@anholt.net>
parent 2bd34f6c
...@@ -104,7 +104,7 @@ static int intel_agp_map_memory(struct agp_memory *mem) ...@@ -104,7 +104,7 @@ static int intel_agp_map_memory(struct agp_memory *mem)
DBG("try mapping %lu pages\n", (unsigned long)mem->page_count); DBG("try mapping %lu pages\n", (unsigned long)mem->page_count);
if (sg_alloc_table(&st, mem->page_count, GFP_KERNEL)) if (sg_alloc_table(&st, mem->page_count, GFP_KERNEL))
return -ENOMEM; goto err;
mem->sg_list = sg = st.sgl; mem->sg_list = sg = st.sgl;
...@@ -113,11 +113,14 @@ static int intel_agp_map_memory(struct agp_memory *mem) ...@@ -113,11 +113,14 @@ static int intel_agp_map_memory(struct agp_memory *mem)
mem->num_sg = pci_map_sg(intel_private.pcidev, mem->sg_list, mem->num_sg = pci_map_sg(intel_private.pcidev, mem->sg_list,
mem->page_count, PCI_DMA_BIDIRECTIONAL); mem->page_count, PCI_DMA_BIDIRECTIONAL);
if (unlikely(!mem->num_sg)) { if (unlikely(!mem->num_sg))
intel_agp_free_sglist(mem); goto err;
return -ENOMEM;
}
return 0; return 0;
err:
sg_free_table(&st);
return -ENOMEM;
} }
static void intel_agp_unmap_memory(struct agp_memory *mem) static void intel_agp_unmap_memory(struct agp_memory *mem)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment