aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char/drm/drm_ioctl.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/char/drm/drm_ioctl.c')
-rw-r--r--drivers/char/drm/drm_ioctl.c27
1 files changed, 14 insertions, 13 deletions
diff --git a/drivers/char/drm/drm_ioctl.c b/drivers/char/drm/drm_ioctl.c
index 9b0feba6b063..bcd4e604d3ec 100644
--- a/drivers/char/drm/drm_ioctl.c
+++ b/drivers/char/drm/drm_ioctl.c
@@ -137,17 +137,22 @@ int drm_setunique(struct inode *inode, struct file *filp,
137 137
138static int drm_set_busid(drm_device_t * dev) 138static int drm_set_busid(drm_device_t * dev)
139{ 139{
140 int len;
141
140 if (dev->unique != NULL) 142 if (dev->unique != NULL)
141 return EBUSY; 143 return EBUSY;
142 144
143 dev->unique_len = 20; 145 dev->unique_len = 40;
144 dev->unique = drm_alloc(dev->unique_len + 1, DRM_MEM_DRIVER); 146 dev->unique = drm_alloc(dev->unique_len + 1, DRM_MEM_DRIVER);
145 if (dev->unique == NULL) 147 if (dev->unique == NULL)
146 return ENOMEM; 148 return ENOMEM;
147 149
148 snprintf(dev->unique, dev->unique_len, "pci:%04x:%02x:%02x.%d", 150 len = snprintf(dev->unique, dev->unique_len, "pci:%04x:%02x:%02x.%d",
149 dev->pci_domain, dev->pci_bus, dev->pci_slot, dev->pci_func); 151 dev->pci_domain, dev->pci_bus, dev->pci_slot, dev->pci_func);
150 152
153 if (len > dev->unique_len)
154 DRM_ERROR("Unique buffer overflowed\n");
155
151 dev->devname = 156 dev->devname =
152 drm_alloc(strlen(dev->driver->pci_driver.name) + dev->unique_len + 157 drm_alloc(strlen(dev->driver->pci_driver.name) + dev->unique_len +
153 2, DRM_MEM_DRIVER); 158 2, DRM_MEM_DRIVER);
@@ -239,7 +244,7 @@ int drm_getclient(struct inode *inode, struct file *filp,
239{ 244{
240 drm_file_t *priv = filp->private_data; 245 drm_file_t *priv = filp->private_data;
241 drm_device_t *dev = priv->head->dev; 246 drm_device_t *dev = priv->head->dev;
242 drm_client_t __user *argp = (void __user *)arg; 247 drm_client_t __user *argp = (drm_client_t __user *)arg;
243 drm_client_t client; 248 drm_client_t client;
244 drm_file_t *pt; 249 drm_file_t *pt;
245 int idx; 250 int idx;
@@ -262,7 +267,7 @@ int drm_getclient(struct inode *inode, struct file *filp,
262 client.iocs = pt->ioctl_count; 267 client.iocs = pt->ioctl_count;
263 up(&dev->struct_sem); 268 up(&dev->struct_sem);
264 269
265 if (copy_to_user((drm_client_t __user *) arg, &client, sizeof(client))) 270 if (copy_to_user(argp, &client, sizeof(client)))
266 return -EFAULT; 271 return -EFAULT;
267 return 0; 272 return 0;
268} 273}
@@ -325,17 +330,13 @@ int drm_setversion(DRM_IOCTL_ARGS)
325 drm_set_version_t retv; 330 drm_set_version_t retv;
326 int if_version; 331 int if_version;
327 drm_set_version_t __user *argp = (void __user *)data; 332 drm_set_version_t __user *argp = (void __user *)data;
328 drm_version_t version;
329 333
330 DRM_COPY_FROM_USER_IOCTL(sv, argp, sizeof(sv)); 334 DRM_COPY_FROM_USER_IOCTL(sv, argp, sizeof(sv));
331 335
332 memset(&version, 0, sizeof(version));
333
334 dev->driver->version(&version);
335 retv.drm_di_major = DRM_IF_MAJOR; 336 retv.drm_di_major = DRM_IF_MAJOR;
336 retv.drm_di_minor = DRM_IF_MINOR; 337 retv.drm_di_minor = DRM_IF_MINOR;
337 retv.drm_dd_major = version.version_major; 338 retv.drm_dd_major = dev->driver->major;
338 retv.drm_dd_minor = version.version_minor; 339 retv.drm_dd_minor = dev->driver->minor;
339 340
340 DRM_COPY_TO_USER_IOCTL(argp, retv, sizeof(sv)); 341 DRM_COPY_TO_USER_IOCTL(argp, retv, sizeof(sv));
341 342
@@ -343,7 +344,7 @@ int drm_setversion(DRM_IOCTL_ARGS)
343 if (sv.drm_di_major != DRM_IF_MAJOR || 344 if (sv.drm_di_major != DRM_IF_MAJOR ||
344 sv.drm_di_minor < 0 || sv.drm_di_minor > DRM_IF_MINOR) 345 sv.drm_di_minor < 0 || sv.drm_di_minor > DRM_IF_MINOR)
345 return EINVAL; 346 return EINVAL;
346 if_version = DRM_IF_VERSION(sv.drm_di_major, sv.drm_dd_minor); 347 if_version = DRM_IF_VERSION(sv.drm_di_major, sv.drm_di_minor);
347 dev->if_version = DRM_MAX(if_version, dev->if_version); 348 dev->if_version = DRM_MAX(if_version, dev->if_version);
348 if (sv.drm_di_minor >= 1) { 349 if (sv.drm_di_minor >= 1) {
349 /* 350 /*
@@ -354,9 +355,9 @@ int drm_setversion(DRM_IOCTL_ARGS)
354 } 355 }
355 356
356 if (sv.drm_dd_major != -1) { 357 if (sv.drm_dd_major != -1) {
357 if (sv.drm_dd_major != version.version_major || 358 if (sv.drm_dd_major != dev->driver->major ||
358 sv.drm_dd_minor < 0 359 sv.drm_dd_minor < 0
359 || sv.drm_dd_minor > version.version_minor) 360 || sv.drm_dd_minor > dev->driver->minor)
360 return EINVAL; 361 return EINVAL;
361 362
362 if (dev->driver->set_version) 363 if (dev->driver->set_version)