userns: Convert drm to use kuid and kgid and struct pid where appropriate
[deliverable/linux.git] / drivers / gpu / drm / drm_fops.c
index d25a61739a7bb7ccf49db4ecde06551ac4b57e0b..433d2fad1fe61ba03a17db26bfc945ddaccea67d 100644 (file)
@@ -140,12 +140,12 @@ int drm_open(struct inode *inode, struct file *filp)
        }
        if (!retcode) {
                mutex_lock(&dev->struct_mutex);
-               if (minor->type == DRM_MINOR_LEGACY) {
-                       if (dev->dev_mapping == NULL)
-                               dev->dev_mapping = inode->i_mapping;
-                       else if (dev->dev_mapping != inode->i_mapping)
-                               retcode = -ENODEV;
-               }
+               if (dev->dev_mapping == NULL)
+                       dev->dev_mapping = &inode->i_data;
+               /* ihold ensures nobody can remove inode with our i_data */
+               ihold(container_of(dev->dev_mapping, struct inode, i_data));
+               inode->i_mapping = dev->dev_mapping;
+               filp->f_mapping = dev->dev_mapping;
                mutex_unlock(&dev->struct_mutex);
        }
 
@@ -251,7 +251,7 @@ static int drm_open_helper(struct inode *inode, struct file *filp,
        filp->private_data = priv;
        priv->filp = filp;
        priv->uid = current_euid();
-       priv->pid = task_pid_nr(current);
+       priv->pid = get_pid(task_pid(current));
        priv->minor = idr_find(&drm_minors_idr, minor_id);
        priv->ioctl_count = 0;
        /* for compatibility root is always authenticated */
@@ -509,6 +509,9 @@ int drm_release(struct inode *inode, struct file *filp)
                }
        }
 
+       BUG_ON(dev->dev_mapping == NULL);
+       iput(container_of(dev->dev_mapping, struct inode, i_data));
+
        /* drop the reference held my the file priv */
        drm_master_put(&file_priv->master);
        file_priv->is_master = 0;
@@ -521,6 +524,7 @@ int drm_release(struct inode *inode, struct file *filp)
        if (drm_core_check_feature(dev, DRIVER_PRIME))
                drm_prime_destroy_file_private(&file_priv->prime);
 
+       put_pid(file_priv->pid);
        kfree(file_priv);
 
        /* ========================================================
This page took 0.025514 seconds and 5 git commands to generate.