drm: Make DRM_IOCTL_GET_CLIENT return EINVAL when it can't find client #idx.
authorEric Anholt <eric@anholt.net>
Thu, 22 Nov 2007 08:46:54 +0000 (18:46 +1000)
committerDave Airlie <airlied@redhat.com>
Thu, 7 Feb 2008 05:09:39 +0000 (15:09 +1000)
Fixes the getclient test and dritest -c.

Signed-off-by: Dave Airlie <airlied@linux.ie>
drivers/char/drm/drm_ioctl.c

index b4d86a3343c6cc13d6759f61c6ee332a1eac266b..16829fb3089d8adbfadda119d427e65bcaa8157c 100644 (file)
@@ -235,25 +235,22 @@ int drm_getclient(struct drm_device *dev, void *data,
        idx = client->idx;
        mutex_lock(&dev->struct_mutex);
 
-       if (list_empty(&dev->filelist)) {
-               mutex_unlock(&dev->struct_mutex);
-               return -EINVAL;
-       }
-
        i = 0;
        list_for_each_entry(pt, &dev->filelist, lhead) {
-               if (i++ >= idx)
-                       break;
+               if (i++ >= idx) {
+                       client->auth = pt->authenticated;
+                       client->pid = pt->pid;
+                       client->uid = pt->uid;
+                       client->magic = pt->magic;
+                       client->iocs = pt->ioctl_count;
+                       mutex_unlock(&dev->struct_mutex);
+
+                       return 0;
+               }
        }
-
-       client->auth = pt->authenticated;
-       client->pid = pt->pid;
-       client->uid = pt->uid;
-       client->magic = pt->magic;
-       client->iocs = pt->ioctl_count;
        mutex_unlock(&dev->struct_mutex);
 
-       return 0;
+       return -EINVAL;
 }
 
 /**