Skip to content

Commit

Permalink
drm/shmem: Cleanup drm_gem_shmem_create_with_handle()
Browse files Browse the repository at this point in the history
Once we create the handle, the handle owns the reference.  Currently
nothing was doing anything with the shmem ptr after the handle was
created, but let's change drm_gem_shmem_create_with_handle() to not
return the pointer, so-as to not encourage problematic use of this
function in the future.  As a bonus, it makes the code a bit cleaner.

Signed-off-by: Rob Clark <robdclark@chromium.org>
  • Loading branch information
robclark authored and intel-lab-lkp committed Jan 19, 2023
1 parent ebd05c0 commit 0de4f64
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions drivers/gpu/drm/drm_gem_shmem_helper.c
Expand Up @@ -415,7 +415,7 @@ void drm_gem_shmem_vunmap(struct drm_gem_shmem_object *shmem,
}
EXPORT_SYMBOL(drm_gem_shmem_vunmap);

static struct drm_gem_shmem_object *
static int
drm_gem_shmem_create_with_handle(struct drm_file *file_priv,
struct drm_device *dev, size_t size,
uint32_t *handle)
Expand All @@ -434,10 +434,8 @@ drm_gem_shmem_create_with_handle(struct drm_file *file_priv,
ret = drm_gem_handle_create(file_priv, &shmem->base, handle);
/* drop reference from allocate - handle holds it now. */
drm_gem_object_put(&shmem->base);
if (ret)
return ERR_PTR(ret);

return shmem;
return ret;
}

/* Update madvise status, returns true if not purged, else
Expand Down Expand Up @@ -533,9 +531,7 @@ int drm_gem_shmem_dumb_create(struct drm_file *file, struct drm_device *dev,
args->size = PAGE_ALIGN(args->pitch * args->height);
}

shmem = drm_gem_shmem_create_with_handle(file, dev, args->size, &args->handle);

return PTR_ERR_OR_ZERO(shmem);
return drm_gem_shmem_create_with_handle(file, dev, args->size, &args->handle);
}
EXPORT_SYMBOL_GPL(drm_gem_shmem_dumb_create);

Expand Down

0 comments on commit 0de4f64

Please sign in to comment.