File revert-drm-replace_fops.diff of Package drm

---
 drivers/gpu/drm/drm_drv.c |   18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)

--- a/drivers/gpu/drm/drm_drv.c
+++ b/drivers/gpu/drm/drm_drv.c
@@ -834,7 +834,7 @@ EXPORT_SYMBOL(drm_dev_set_unique);
 
 static int drm_stub_open(struct inode *inode, struct file *filp)
 {
-	const struct file_operations *new_fops;
+	const struct file_operations *old_fops;
 	struct drm_minor *minor;
 	int err;
 
@@ -847,17 +847,23 @@ static int drm_stub_open(struct inode *i
 		goto out_unlock;
 	}
 
-	new_fops = fops_get(minor->dev->driver->fops);
-	if (!new_fops) {
+	old_fops = filp->f_op;
+	filp->f_op = fops_get(minor->dev->driver->fops);
+	if (filp->f_op == NULL) {
+		filp->f_op = old_fops;
 		err = -ENODEV;
 		goto out_release;
 	}
 
-	replace_fops(filp, new_fops);
-	if (filp->f_op->open)
+	if (filp->f_op->open) {
 		err = filp->f_op->open(inode, filp);
-	else
+		if (err) {
+			fops_put(filp->f_op);
+			filp->f_op = fops_get(old_fops);
+		}
+	} else
 		err = 0;
+	fops_put(old_fops);
 
 out_release:
 	drm_minor_release(minor);