[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAL_Jsq+So-kadir8o8T-YNYkfOYD8vopAS3UWGbSdRVLjH_JGQ@mail.gmail.com>
Date: Mon, 8 Apr 2019 15:09:06 -0500
From: Rob Herring <robh@...nel.org>
To: Eric Anholt <eric@...olt.net>
Cc: Chris Wilson <chris@...is-wilson.co.uk>,
Daniel Vetter <daniel@...ll.ch>,
Neil Armstrong <narmstrong@...libre.com>,
Maxime Ripard <maxime.ripard@...tlin.com>,
Robin Murphy <robin.murphy@....com>,
Will Deacon <will.deacon@....com>,
Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
dri-devel <dri-devel@...ts.freedesktop.org>,
David Airlie <airlied@...ux.ie>,
"list@....net:IOMMU DRIVERS <iommu@...ts.linux-foundation.org>, Joerg
Roedel <joro@...tes.org>," <iommu@...ts.linux-foundation.org>,
Linux ARM <linux-arm-kernel@...ts.infradead.org>,
Sean Paul <sean@...rly.run>,
Alyssa Rosenzweig <alyssa@...enzweig.io>,
Steven Price <steven.price@....com>
Subject: Re: [PATCH v2 2/3] drm: Add a drm_gem_objects_lookup helper
On Mon, Apr 1, 2019 at 10:43 AM Eric Anholt <eric@...olt.net> wrote:
>
> Chris Wilson <chris@...is-wilson.co.uk> writes:
>
> > Quoting Daniel Vetter (2019-04-01 14:06:48)
> >> On Mon, Apr 1, 2019 at 9:47 AM Rob Herring <robh@...nel.org> 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.
Thanks to Steven for noticing this copied code in panfrost.
Rob
Powered by blists - more mailing lists