From 81952c7dd18d8fc4617fe4cb761fdf830de5244f Mon Sep 17 00:00:00 2001 From: Robert Noland Date: Sat, 20 Sep 2008 18:34:57 -0400 Subject: 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. --- bsd-core/drm_vm.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) (limited to 'bsd-core') 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)) { -- cgit v1.2.3