[Intel-gfx] [PATCH] drm: Release driver references to handle before making it available again
Chris Wilson
chris at chris-wilson.co.uk
Fri Jan 8 15:19:14 PST 2016
On Fri, Jan 08, 2016 at 08:25:07PM +0000, Chris Wilson wrote:
> Whilst calling back into the driver, we have to drop the
> file->table_lock spinlock and so to prevent reusing the closed handle we
> mark that handle as stale in the idr, perform the callback and then
> remove the handle. It is then possible for a lookup on that handle to
> return an error object and so all callers of idr_find(file->object_idr)
> need to check against IS_ERR_OR_NULL() instead.
>
> - obj = idr_find(&filp->object_idr, handle);
> - if (obj == NULL) {
> + obj = idr_replace(&filp->object_idr, ERR_PTR(-ENOENT), handle);
> + if (IS_ERR(obj)) {
Setting ERR_PTR(-ENOENT) is superfluous. We can just set the entry to
NULL as idr_alloc() uses a bitmap to find the new handle. This avoids
having to change the callers elsewhere, as idr_find() will then return
NULL for the stale handle and the invalid handle.
-Chris
--
Chris Wilson, Intel Open Source Technology Centre
More information about the Intel-gfx
mailing list