Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm: Make DRM_IOCTL_GET_CLIENT return EINVAL when it can't find client #idx.

Fixes the getclient test and dritest -c.

Signed-off-by: Dave Airlie <airlied@linux.ie>

authored by

Eric Anholt and committed by
Dave Airlie
b018fcda 3260f9fd

+11 -14
+11 -14
drivers/char/drm/drm_ioctl.c
··· 235 235 idx = client->idx; 236 236 mutex_lock(&dev->struct_mutex); 237 237 238 - if (list_empty(&dev->filelist)) { 239 - mutex_unlock(&dev->struct_mutex); 240 - return -EINVAL; 241 - } 242 - 243 238 i = 0; 244 239 list_for_each_entry(pt, &dev->filelist, lhead) { 245 - if (i++ >= idx) 246 - break; 247 - } 240 + if (i++ >= idx) { 241 + client->auth = pt->authenticated; 242 + client->pid = pt->pid; 243 + client->uid = pt->uid; 244 + client->magic = pt->magic; 245 + client->iocs = pt->ioctl_count; 246 + mutex_unlock(&dev->struct_mutex); 248 247 249 - client->auth = pt->authenticated; 250 - client->pid = pt->pid; 251 - client->uid = pt->uid; 252 - client->magic = pt->magic; 253 - client->iocs = pt->ioctl_count; 248 + return 0; 249 + } 250 + } 254 251 mutex_unlock(&dev->struct_mutex); 255 252 256 - return 0; 253 + return -EINVAL; 257 254 } 258 255 259 256 /**