[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20190619103212.GA1896@arch-x1c3>
Date: Wed, 19 Jun 2019 11:32:12 +0100
From: Emil Velikov <emil.l.velikov@...il.com>
To: Gerd Hoffmann <kraxel@...hat.com>
Cc: dri-devel@...ts.freedesktop.org,
Maxime Ripard <maxime.ripard@...tlin.com>,
open list <linux-kernel@...r.kernel.org>,
David Airlie <airlied@...ux.ie>, Sean Paul <sean@...rly.run>
Subject: Re: [PATCH v3 01/12] drm: add gem array helpers
Hi Gerd,
On 2019/06/19, Gerd Hoffmann wrote:
> +/**
> + * drm_gem_array_from_handles -- lookup an array of gem handles.
> + *
> + * @drm_file: drm file-private structure to use for the handle look up
> + * @handles: the array of handles to lookup.
> + * @nents: the numer of handles.
> + *
> + * Returns: An array of gem objects on success, NULL on failure.
> + */
> +struct drm_gem_object_array*
> +drm_gem_array_from_handles(struct drm_file *drm_file, u32 *handles, u32 nents)
> +{
> + struct drm_gem_object_array *objs;
> + u32 i;
> +
> + objs = drm_gem_array_alloc(nents);
> + if (!objs)
> + return NULL;
> +
> + for (i = 0; i < nents; i++) {
> + objs->objs[i] = drm_gem_object_lookup(drm_file, handles[i]);
> + if (!objs->objs[i]) {
Missing object put for the 0..i-1 handles. Personally I would:
objs->nents = i;
drm_gem_array_put_free(objs);
return NULL;
> + drm_gem_array_put_free(objs);
> + return NULL;
> + }
> + }
> + return objs;
> +}
Missing EXPORT_SYMBOL?
> +
> +/**
> + * drm_gem_array_put_free -- put gem objects and free array.
> + *
> + * @objs: the gem object array.
> + */
> +void drm_gem_array_put_free(struct drm_gem_object_array *objs)
> +{
> + u32 i;
> +
> + for (i = 0; i < objs->nents; i++) {
> + if (!objs->objs[i])
> + continue;
> + drm_gem_object_put_unlocked(objs->objs[i]);
> + }
> + drm_gem_array_free(objs);
> +}
Ditto?
HTH
Emil
Powered by blists - more mailing lists