[PATCH 3/3] agp/intel: Destroy the scatterlist on allocation failure

Chris Wilson chris at chris-wilson.co.uk
Tue Jul 27 00:42:33 PDT 2010


On Tue, 27 Jul 2010 10:00:07 +0800, Zhenyu Wang <zhenyuw at linux.intel.com> wrote:
> On 2010.07.24 18:29:37 +0100, Chris Wilson wrote:
> > 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.
> 
> Why? Doesn't sg_alloc_table() handle the failure case to call sg_free_table()
> already?

sg_alloc_table() is just a wrapper around __sg_alloc_table() that passes
in the default alloc_func. So for __sg_alloc_table() to do the cleanup we
would need to also pass in the free_func. Since it doesn't, it can't free
the partially constructed table. So to fix this we have the choice of
changing the interface (and add extra overhead to the common path) or
trivially rearrange our failure path.
-- 
Chris Wilson, Intel Open Source Technology Centre


More information about the dri-devel mailing list