From: Eric Anholt Subject: Re: [PATCH v2 2/3] drm: Add a drm_gem_objects_lookup helper Date: Tue, 09 Apr 2019 09:55:27 -0700 Message-ID: <878swjnmo0.fsf@anholt.net> References: <20190401074730.12241-1-robh@kernel.org> <20190401074730.12241-3-robh@kernel.org> <155412649586.24691.809508732198367112@skylake-alporthouse-com> <8736n120jw.fsf@anholt.net> Mime-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha512; protocol="application/pgp-signature" Return-path: In-Reply-To: Sender: linux-kernel-owner@vger.kernel.org To: Rob Herring Cc: Chris Wilson , Daniel Vetter , Neil Armstrong , Maxime Ripard , Robin Murphy , Will Deacon , Linux Kernel Mailing List , dri-devel , David Airlie , "list@263.net:IOMMU DRIVERS , Joerg Roedel ," , Linux ARM , Sean Paul , Alyssa Rosenzweig , Steven Price List-Id: dri-devel@lists.freedesktop.org --=-=-= Content-Type: text/plain Rob Herring writes: > On Mon, Apr 1, 2019 at 10:43 AM Eric Anholt wrote: >> >> Chris Wilson writes: >> >> > Quoting Daniel Vetter (2019-04-01 14:06:48) >> >> On Mon, Apr 1, 2019 at 9:47 AM Rob Herring wrote: >> >> > +{ >> >> > + int i, ret = 0; >> >> > + struct drm_gem_object *obj; >> >> > + >> >> > + spin_lock(&filp->table_lock); >> >> > + >> >> > + for (i = 0; i < count; i++) { >> >> > + /* Check if we currently have a reference on the object */ >> >> > + obj = idr_find(&filp->object_idr, handle[i]); >> >> > + if (!obj) { >> >> > + ret = -ENOENT; >> > >> > Unwind previous drm_gem_object_get(), the caller has no idea how many >> > were processed before the error. >> >> I had the same thought, but the pattern we have is that you're loading >> into a refcounted struct that will free the BOs when you're done, >> anyway. > > The real bug here is if allocation of the array fails. The BO array > may be NULL when the count is not. So this V3D cleanup hunk: > > for (i = 0; i < exec->bo_count; i++) > drm_gem_object_put_unlocked(&exec->bo[i]->base.base); > kvfree(exec->bo); > > Needs to be wrapped with 'if (exec->bo)'. We have a similar problem > with fence arrays too. Yeah, seems legit. Not really going to write new patches when I've got month-old critical patches I can't get acked, though. :/ --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCgAdFiEE/JuuFDWp9/ZkuCBXtdYpNtH8nugFAlyszn8ACgkQtdYpNtH8 nugquA/8DPK4mN09dn/AZq67osFqFl6wN3K0sqmG6JaW+Opu7DkzH10fmUthRfbD +q2HSJATWQbIP04FLmCmOp6AeqfWV7aX8jB39ltn3EHxuFb0qdLyFm/Rp6Tyr+sb yn+GknjYKzO56+SZFoaIJuBcpZKEUjaxhfr85fgJxfR0nR7B2wH3n+IIRf+dFWeO 6hmRFNzENYeaPgQCHkNnYLxXnQDIDZ+eScp1Z3CwpU4LCJFEM6LylXx7xordg9qa ljfYYT/asSruPYpvTjiQ2fhvlsgFizn6uA4R//Ls45LMtQaT/4gnCFuAI8w8559O ppg7QkBHqbUYji7bSZVQzQwp/QNAGwg/aVbaKrLCj1hFRxj73e9VllofndapQV45 Vv/5CYaG84CntgdN8AK34R1s90NHDRkGJV9A3FaY/9sTk1y7uV+OArcdsChhNNRT m4eq1cBGwA4n8ZuxbApcM0m0e6oA6qMxathbeIaTab5UEYnlWl3UTsXaOT0EEuDx A0XRCq1X2natvm9Zf40AX9p4WUDH1eNE7DJyIHO7LY2jC++7v2YwWK2T/ccS09tK QUAhTvQc4wlCBTIz40s7cWcxPmEWQuhcaAnY6e499HZPiE0RoLarMh42t/fiz+Rp Ie3qcv6nRTNQHWJrGCKiKbQEiNK2MSzJxptXA0KGwFcvlp41CcY= =vGS6 -----END PGP SIGNATURE----- --=-=-=--