diff options
author | Robert Noland <rnoland@2hip.net> | 2008-09-20 18:34:57 -0400 |
---|---|---|
committer | Robert Noland <rnoland@2hip.net> | 2008-10-01 20:49:03 -0400 |
commit | 81952c7dd18d8fc4617fe4cb761fdf830de5244f (patch) | |
tree | a06ad21e5e4eb6c211f5a7b30a8b1275a4adef72 /bsd-core | |
parent | 073cb5ee1d12a7f1a18b7d732f346c16eb740f49 (diff) |
Use devfs_get_cdevpriv in mmap as well.
d_mmap gets called twice and we are only able to associate the file_priv
during the first call. The second call will return EBADF and we need to
assume that the call was succesful. d_mmap will not tolerate having an
error returned for the second call.
Diffstat (limited to 'bsd-core')
-rw-r--r-- | bsd-core/drm_vm.c | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/bsd-core/drm_vm.c b/bsd-core/drm_vm.c index 8ee49a28..4bc6f46a 100644 --- a/bsd-core/drm_vm.c +++ b/bsd-core/drm_vm.c @@ -32,20 +32,23 @@ int drm_mmap(struct cdev *kdev, vm_offset_t offset, vm_paddr_t *paddr, int prot) { struct drm_device *dev = drm_get_device_from_kdev(kdev); - struct drm_file *file_priv; + struct drm_file *file_priv = NULL; drm_local_map_t *map; enum drm_map_type type; vm_paddr_t phys; + int error; - DRM_LOCK(); - TAILQ_FOREACH(file_priv, &dev->files, link) - if (file_priv->pid == curthread->td_proc->p_pid && - file_priv->uid == curthread->td_ucred->cr_svuid && - file_priv->authenticated == 1) - break; - DRM_UNLOCK(); + /* d_mmap gets called twice, we can only reference file_priv during + * the first call. We need to assume that if error is EBADF the + * call was succesful and the client is authenticated. + */ + error = devfs_get_cdevpriv((void **)&file_priv); + if (error == ENOENT) { + DRM_ERROR("Could not find authenticator!\n"); + return EINVAL; + } - if (!file_priv) + if (file_priv && !file_priv->authenticated) return EACCES; if (dev->dma && offset >= 0 && offset < ptoa(dev->dma->page_count)) { |