From mboxrd@z Thu Jan 1 00:00:00 1970 From: Zhenyu Wang Subject: Re: [PATCH 3/3] agp/intel: Destroy the scatterlist on allocation failure Date: Tue, 27 Jul 2010 10:00:07 +0800 Message-ID: <20100727020007.GC19248@zhen-devel.sh.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> Reply-To: Zhenyu Wang Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============1484060264==" Return-path: Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by gabe.freedesktop.org (Postfix) with ESMTP id 131EE9E75A for ; Mon, 26 Jul 2010 19:00:09 -0700 (PDT) In-Reply-To: <1279992577-31841-3-git-send-email-chris@chris-wilson.co.uk> 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: Chris Wilson Cc: dri-devel@lists.freedesktop.org List-Id: dri-devel@lists.freedesktop.org --===============1484060264== Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="48TaNjbzBVislYPb" Content-Disposition: inline --48TaNjbzBVislYPb Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable 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? >=20 > Signed-off-by: Chris Wilson > Cc Dave Airlie > --- > drivers/char/agp/intel-gtt.c | 13 ++++++++----- > 1 files changed, 8 insertions(+), 5 deletions(-) >=20 > diff --git a/drivers/char/agp/intel-gtt.c b/drivers/char/agp/intel-gtt.c > index f97122a..5615d70 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 *me= m) > DBG("try mapping %lu pages\n", (unsigned long)mem->page_count); > =20 > if (sg_alloc_table(&st, mem->page_count, GFP_KERNEL)) > - return -ENOMEM; > + goto err; > =20 > mem->sg_list =3D sg =3D st.sgl; > =20 > @@ -113,11 +113,14 @@ static int intel_agp_map_memory(struct agp_memory *= mem) > =20 > mem->num_sg =3D pci_map_sg(intel_private.pcidev, mem->sg_list, > mem->page_count, PCI_DMA_BIDIRECTIONAL); > - if (unlikely(!mem->num_sg)) { > - intel_agp_free_sglist(mem); > - return -ENOMEM; > - } > + if (unlikely(!mem->num_sg)) > + goto err; > + > return 0; > + > +err: > + sg_free_table(&st); > + return -ENOMEM; > } > =20 > static void intel_agp_unmap_memory(struct agp_memory *mem) > --=20 > 1.7.1 >=20 > _______________________________________________ > dri-devel mailing list > dri-devel@lists.freedesktop.org > http://lists.freedesktop.org/mailman/listinfo/dri-devel --=20 Open Source Technology Center, Intel ltd. $gpg --keyserver wwwkeys.pgp.net --recv-keys 4D781827 --48TaNjbzBVislYPb Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.10 (GNU/Linux) iEYEARECAAYFAkxOPacACgkQsQQaM014GCd6ggCfZ+a4/StswxWh5gggau3xxngC DX4AnA9tZ1i6QwLXt0KP0RQ49rVlWZG2 =Xusy -----END PGP SIGNATURE----- --48TaNjbzBVislYPb-- --===============1484060264== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ dri-devel mailing list dri-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/dri-devel --===============1484060264==--