diff options
Diffstat (limited to 'drivers/uio')
-rw-r--r-- | drivers/uio/uio.c | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/drivers/uio/uio.c b/drivers/uio/uio.c index 55cc7b80422a..5a7ca2e6094d 100644 --- a/drivers/uio/uio.c +++ b/drivers/uio/uio.c | |||
@@ -297,12 +297,17 @@ static int uio_open(struct inode *inode, struct file *filep) | |||
297 | struct uio_listener *listener; | 297 | struct uio_listener *listener; |
298 | int ret = 0; | 298 | int ret = 0; |
299 | 299 | ||
300 | lock_kernel(); | ||
300 | idev = idr_find(&uio_idr, iminor(inode)); | 301 | idev = idr_find(&uio_idr, iminor(inode)); |
301 | if (!idev) | 302 | if (!idev) { |
302 | return -ENODEV; | 303 | ret = -ENODEV; |
304 | goto out; | ||
305 | } | ||
303 | 306 | ||
304 | if (!try_module_get(idev->owner)) | 307 | if (!try_module_get(idev->owner)) { |
305 | return -ENODEV; | 308 | ret = -ENODEV; |
309 | goto out; | ||
310 | } | ||
306 | 311 | ||
307 | listener = kmalloc(sizeof(*listener), GFP_KERNEL); | 312 | listener = kmalloc(sizeof(*listener), GFP_KERNEL); |
308 | if (!listener) { | 313 | if (!listener) { |
@@ -319,7 +324,7 @@ static int uio_open(struct inode *inode, struct file *filep) | |||
319 | if (ret) | 324 | if (ret) |
320 | goto err_infoopen; | 325 | goto err_infoopen; |
321 | } | 326 | } |
322 | 327 | unlock_kernel(); | |
323 | return 0; | 328 | return 0; |
324 | 329 | ||
325 | err_infoopen: | 330 | err_infoopen: |
@@ -329,6 +334,8 @@ err_alloc_listener: | |||
329 | 334 | ||
330 | module_put(idev->owner); | 335 | module_put(idev->owner); |
331 | 336 | ||
337 | out: | ||
338 | unlock_kernel(); | ||
332 | return ret; | 339 | return ret; |
333 | } | 340 | } |
334 | 341 | ||
@@ -649,15 +656,14 @@ int __uio_register_device(struct module *owner, | |||
649 | if (ret) | 656 | if (ret) |
650 | goto err_get_minor; | 657 | goto err_get_minor; |
651 | 658 | ||
652 | idev->dev = device_create(uio_class->class, parent, | 659 | idev->dev = device_create_drvdata(uio_class->class, parent, |
653 | MKDEV(uio_major, idev->minor), | 660 | MKDEV(uio_major, idev->minor), idev, |
654 | "uio%d", idev->minor); | 661 | "uio%d", idev->minor); |
655 | if (IS_ERR(idev->dev)) { | 662 | if (IS_ERR(idev->dev)) { |
656 | printk(KERN_ERR "UIO: device register failed\n"); | 663 | printk(KERN_ERR "UIO: device register failed\n"); |
657 | ret = PTR_ERR(idev->dev); | 664 | ret = PTR_ERR(idev->dev); |
658 | goto err_device_create; | 665 | goto err_device_create; |
659 | } | 666 | } |
660 | dev_set_drvdata(idev->dev, idev); | ||
661 | 667 | ||
662 | ret = uio_dev_add_attributes(idev); | 668 | ret = uio_dev_add_attributes(idev); |
663 | if (ret) | 669 | if (ret) |