aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char/drm/drm_auth.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/char/drm/drm_auth.c')
-rw-r--r--drivers/char/drm/drm_auth.c36
1 files changed, 15 insertions, 21 deletions
diff --git a/drivers/char/drm/drm_auth.c b/drivers/char/drm/drm_auth.c
index dc66cfef7ec3..a73462723d2d 100644
--- a/drivers/char/drm/drm_auth.c
+++ b/drivers/char/drm/drm_auth.c
@@ -137,32 +137,29 @@ static int drm_remove_magic(struct drm_device * dev, drm_magic_t magic)
137 * searches an unique non-zero magic number and add it associating it with \p 137 * searches an unique non-zero magic number and add it associating it with \p
138 * file_priv. 138 * file_priv.
139 */ 139 */
140int drm_getmagic(struct inode *inode, struct drm_file *file_priv, 140int drm_getmagic(struct drm_device *dev, void *data, struct drm_file *file_priv)
141 unsigned int cmd, unsigned long arg)
142{ 141{
143 static drm_magic_t sequence = 0; 142 static drm_magic_t sequence = 0;
144 static DEFINE_SPINLOCK(lock); 143 static DEFINE_SPINLOCK(lock);
145 struct drm_device *dev = file_priv->head->dev; 144 struct drm_auth *auth = data;
146 struct drm_auth auth;
147 145
148 /* Find unique magic */ 146 /* Find unique magic */
149 if (file_priv->magic) { 147 if (file_priv->magic) {
150 auth.magic = file_priv->magic; 148 auth->magic = file_priv->magic;
151 } else { 149 } else {
152 do { 150 do {
153 spin_lock(&lock); 151 spin_lock(&lock);
154 if (!sequence) 152 if (!sequence)
155 ++sequence; /* reserve 0 */ 153 ++sequence; /* reserve 0 */
156 auth.magic = sequence++; 154 auth->magic = sequence++;
157 spin_unlock(&lock); 155 spin_unlock(&lock);
158 } while (drm_find_file(dev, auth.magic)); 156 } while (drm_find_file(dev, auth->magic));
159 file_priv->magic = auth.magic; 157 file_priv->magic = auth->magic;
160 drm_add_magic(dev, file_priv, auth.magic); 158 drm_add_magic(dev, file_priv, auth->magic);
161 } 159 }
162 160
163 DRM_DEBUG("%u\n", auth.magic); 161 DRM_DEBUG("%u\n", auth->magic);
164 if (copy_to_user((struct drm_auth __user *) arg, &auth, sizeof(auth))) 162
165 return -EFAULT;
166 return 0; 163 return 0;
167} 164}
168 165
@@ -177,19 +174,16 @@ int drm_getmagic(struct inode *inode, struct drm_file *file_priv,
177 * 174 *
178 * Checks if \p file_priv is associated with the magic number passed in \arg. 175 * Checks if \p file_priv is associated with the magic number passed in \arg.
179 */ 176 */
180int drm_authmagic(struct inode *inode, struct drm_file *file_priv, 177int drm_authmagic(struct drm_device *dev, void *data,
181 unsigned int cmd, unsigned long arg) 178 struct drm_file *file_priv)
182{ 179{
183 struct drm_device *dev = file_priv->head->dev; 180 struct drm_auth *auth = data;
184 struct drm_auth auth;
185 struct drm_file *file; 181 struct drm_file *file;
186 182
187 if (copy_from_user(&auth, (struct drm_auth __user *) arg, sizeof(auth))) 183 DRM_DEBUG("%u\n", auth->magic);
188 return -EFAULT; 184 if ((file = drm_find_file(dev, auth->magic))) {
189 DRM_DEBUG("%u\n", auth.magic);
190 if ((file = drm_find_file(dev, auth.magic))) {
191 file->authenticated = 1; 185 file->authenticated = 1;
192 drm_remove_magic(dev, auth.magic); 186 drm_remove_magic(dev, auth->magic);
193 return 0; 187 return 0;
194 } 188 }
195 return -EINVAL; 189 return -EINVAL;