Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5d3a26a5 authored by qctecmdr's avatar qctecmdr Committed by Gerrit - the friendly Code Review server
Browse files

Merge "drm: plug memory leak on drm_setup() failure"

parents 3dad5aa3 dd33f8da
Loading
Loading
Loading
Loading
+16 −6
Original line number Diff line number Diff line
@@ -264,6 +264,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;
@@ -325,9 +337,11 @@ int drm_open(struct inode *inode, struct file *filp)
		goto err_undo;
	if (need_setup) {
		retcode = drm_setup(dev);
		if (retcode)
		if (retcode) {
			drm_close_helper(filp);
			goto err_undo;
		}
	}
	return 0;

err_undo:
@@ -480,11 +494,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);