Skip to content

Commit

Permalink
drm: Make DRM_IOCTL_GET_CLIENT return EINVAL when it can't find clien…
Browse files Browse the repository at this point in the history
…t #idx.

Fixes the getclient test and dritest -c.

Signed-off-by: Dave Airlie <airlied@linux.ie>
  • Loading branch information
Eric Anholt authored and Dave Airlie committed Feb 7, 2008
1 parent 3260f9f commit b018fcd
Showing 1 changed file with 11 additions and 14 deletions.
25 changes: 11 additions & 14 deletions drivers/char/drm/drm_ioctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

/**
Expand Down

0 comments on commit b018fcd

Please sign in to comment.