From mboxrd@z Thu Jan 1 00:00:00 1970 From: Chris Wilson Subject: Re: [PATCH 3/3] agp/intel: Destroy the scatterlist on allocation failure Date: Tue, 27 Jul 2010 08:42:33 +0100 Message-ID: <89k83a$92jplm@azsmga001.ch.intel.com> References: <1279992577-31841-1-git-send-email-chris@chris-wilson.co.uk> <1279992577-31841-3-git-send-email-chris@chris-wilson.co.uk> <20100727020007.GC19248@zhen-devel.sh.intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mga03.intel.com (mga03.intel.com [143.182.124.21]) by gabe.freedesktop.org (Postfix) with ESMTP id 927309E7E3 for ; Tue, 27 Jul 2010 00:42:36 -0700 (PDT) In-Reply-To: <20100727020007.GC19248@zhen-devel.sh.intel.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: dri-devel-bounces+sf-dri-devel=m.gmane.org@lists.freedesktop.org Errors-To: dri-devel-bounces+sf-dri-devel=m.gmane.org@lists.freedesktop.org To: Zhenyu Wang Cc: dri-devel@lists.freedesktop.org List-Id: dri-devel@lists.freedesktop.org On Tue, 27 Jul 2010 10:00:07 +0800, Zhenyu Wang 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