Skip to content

Commit

Permalink
drm: factor out drm_close_helper() function
Browse files Browse the repository at this point in the history
Will be used to plug an existing memory leak.

Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: https://patchwork.freedesktop.org/patch/msgid/20190114084410.15266-1-emil.l.velikov@gmail.com
  • Loading branch information
Emil Velikov authored and Emil Velikov committed Feb 13, 2019
1 parent 4933c9a commit e21710a
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions drivers/gpu/drm/drm_file.c
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,18 @@ void drm_file_free(struct drm_file *file)
kfree(file);
}

static void drm_close_helper(struct file *filp)
{
struct drm_file *file_priv = filp->private_data;
struct drm_device *dev = file_priv->minor->dev;

mutex_lock(&dev->filelist_mutex);
list_del(&file_priv->lhead);
mutex_unlock(&dev->filelist_mutex);

drm_file_free(file_priv);
}

static int drm_setup(struct drm_device * dev)
{
int ret;
Expand Down Expand Up @@ -473,11 +485,7 @@ int drm_release(struct inode *inode, struct file *filp)

DRM_DEBUG("open_count = %d\n", dev->open_count);

mutex_lock(&dev->filelist_mutex);
list_del(&file_priv->lhead);
mutex_unlock(&dev->filelist_mutex);

drm_file_free(file_priv);
drm_close_helper(filp);

if (!--dev->open_count) {
drm_lastclose(dev);
Expand Down

0 comments on commit e21710a

Please sign in to comment.