All of lore.kernel.org
 help / color / mirror / Atom feed
From: David Herrmann <dh.herrmann@gmail.com>
To: dri-devel@lists.freedesktop.org
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Subject: [PATCH 7/8] drm: rename drm_file.filp to drm_file.legacy_filp
Date: Wed,  3 Aug 2016 20:04:31 +0200	[thread overview]
Message-ID: <20160803180432.1341-8-dh.herrmann@gmail.com> (raw)
In-Reply-To: <20160803180432.1341-1-dh.herrmann@gmail.com>

We don't want anyone but legacy DRM1 code to use drm_file.filp. Especially
for in-kernel contexts, this might be set to NULL, so lets make sure
no-one accesses it, ever.

Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
---
 drivers/gpu/drm/drm_bufs.c | 7 ++++---
 drivers/gpu/drm/drm_fops.c | 2 +-
 include/drm/drmP.h         | 2 +-
 3 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/drm_bufs.c b/drivers/gpu/drm/drm_bufs.c
index c3a12cd..d2803de 100644
--- a/drivers/gpu/drm/drm_bufs.c
+++ b/drivers/gpu/drm/drm_bufs.c
@@ -1456,7 +1456,7 @@ int drm_legacy_mapbufs(struct drm_device *dev, void *data,
 	if (!drm_core_check_feature(dev, DRIVER_HAVE_DMA))
 		return -EINVAL;
 
-	if (!dma)
+	if (!dma || !file_priv->legacy_filp)
 		return -EINVAL;
 
 	spin_lock(&dev->buf_lock);
@@ -1478,12 +1478,13 @@ int drm_legacy_mapbufs(struct drm_device *dev, void *data,
 				retcode = -EINVAL;
 				goto done;
 			}
-			virtual = vm_mmap(file_priv->filp, 0, map->size,
+			virtual = vm_mmap(file_priv->legacy_filp, 0, map->size,
 					  PROT_READ | PROT_WRITE,
 					  MAP_SHARED,
 					  token);
 		} else {
-			virtual = vm_mmap(file_priv->filp, 0, dma->byte_count,
+			virtual = vm_mmap(file_priv->legacy_filp, 0,
+					  dma->byte_count,
 					  PROT_READ | PROT_WRITE,
 					  MAP_SHARED, 0);
 		}
diff --git a/drivers/gpu/drm/drm_fops.c b/drivers/gpu/drm/drm_fops.c
index e9d66f5..69ef23c 100644
--- a/drivers/gpu/drm/drm_fops.c
+++ b/drivers/gpu/drm/drm_fops.c
@@ -198,7 +198,7 @@ static int drm_open_helper(struct file *filp, struct drm_minor *minor)
 		return -ENOMEM;
 
 	filp->private_data = priv;
-	priv->filp = filp;
+	priv->legacy_filp = filp;
 	priv->pid = get_pid(task_pid(current));
 	priv->minor = minor;
 
diff --git a/include/drm/drmP.h b/include/drm/drmP.h
index 0f69f56..2197ab1 100644
--- a/include/drm/drmP.h
+++ b/include/drm/drmP.h
@@ -330,7 +330,7 @@ struct drm_file {
 	/** Lock for synchronization of access to object_idr. */
 	spinlock_t table_lock;
 
-	struct file *filp;
+	struct file *legacy_filp; /* might be NULL! */
 	void *driver_priv;
 
 	struct drm_master *master; /* master this node is currently associated with
-- 
2.9.2

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

  parent reply	other threads:[~2016-08-03 18:05 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-03 18:04 [PATCH 0/8] DRM File Context Cleanups David Herrmann
2016-08-03 18:04 ` [PATCH 1/8] drm: rename DRM_MINOR_LEGACY to DRM_MINOR_PRIMARY David Herrmann
2016-08-04  7:45   ` Frank Binns
2016-08-04  8:16     ` Daniel Vetter
2016-08-03 18:04 ` [PATCH 2/8] drm: remove redundant drm_file->uid David Herrmann
2016-08-03 18:57   ` Chris Wilson
2016-08-03 19:01   ` Chris Wilson
2016-08-04  8:29     ` David Herrmann
2016-08-03 18:04 ` [PATCH 3/8] drm: reduce GETCLIENT to a minimum David Herrmann
2016-08-03 18:04 ` [PATCH 4/8] drm: make vma-manager entries untyped David Herrmann
2016-08-03 18:51   ` Chris Wilson
2016-08-04  9:29   ` Emil Velikov
2016-08-03 18:04 ` [PATCH 5/8] drm: use drm_file to tag vm-bos David Herrmann
2016-08-03 19:08   ` Chris Wilson
2016-08-04  8:16     ` Daniel Vetter
2016-08-04  8:30       ` David Herrmann
2016-08-03 18:04 ` [PATCH 6/8] drm: use priv->pid to deduce task EUID David Herrmann
2016-08-03 18:58   ` Chris Wilson
2016-08-03 18:04 ` David Herrmann [this message]
2016-08-03 18:04 ` [PATCH 8/8] drm: provide management functions for drm_file David Herrmann

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20160803180432.1341-8-dh.herrmann@gmail.com \
    --to=dh.herrmann@gmail.com \
    --cc=daniel.vetter@ffwll.ch \
    --cc=dri-devel@lists.freedesktop.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.