diff options
Diffstat (limited to 'drivers/gpu/drm/drm_fops.c')
-rw-r--r-- | drivers/gpu/drm/drm_fops.c | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/drivers/gpu/drm/drm_fops.c b/drivers/gpu/drm/drm_fops.c index d25a61739a7b..5062eec673f1 100644 --- a/drivers/gpu/drm/drm_fops.c +++ b/drivers/gpu/drm/drm_fops.c | |||
@@ -140,12 +140,12 @@ int drm_open(struct inode *inode, struct file *filp) | |||
140 | } | 140 | } |
141 | if (!retcode) { | 141 | if (!retcode) { |
142 | mutex_lock(&dev->struct_mutex); | 142 | mutex_lock(&dev->struct_mutex); |
143 | if (minor->type == DRM_MINOR_LEGACY) { | 143 | if (dev->dev_mapping == NULL) |
144 | if (dev->dev_mapping == NULL) | 144 | dev->dev_mapping = &inode->i_data; |
145 | dev->dev_mapping = inode->i_mapping; | 145 | /* ihold ensures nobody can remove inode with our i_data */ |
146 | else if (dev->dev_mapping != inode->i_mapping) | 146 | ihold(container_of(dev->dev_mapping, struct inode, i_data)); |
147 | retcode = -ENODEV; | 147 | inode->i_mapping = dev->dev_mapping; |
148 | } | 148 | filp->f_mapping = dev->dev_mapping; |
149 | mutex_unlock(&dev->struct_mutex); | 149 | mutex_unlock(&dev->struct_mutex); |
150 | } | 150 | } |
151 | 151 | ||
@@ -509,6 +509,9 @@ int drm_release(struct inode *inode, struct file *filp) | |||
509 | } | 509 | } |
510 | } | 510 | } |
511 | 511 | ||
512 | BUG_ON(dev->dev_mapping == NULL); | ||
513 | iput(container_of(dev->dev_mapping, struct inode, i_data)); | ||
514 | |||
512 | /* drop the reference held my the file priv */ | 515 | /* drop the reference held my the file priv */ |
513 | drm_master_put(&file_priv->master); | 516 | drm_master_put(&file_priv->master); |
514 | file_priv->is_master = 0; | 517 | file_priv->is_master = 0; |