aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorGreg Kroah-Hartman <gregkh@suse.de>2008-05-16 20:55:12 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2008-05-20 16:31:55 -0400
commit43691da4cefcf0d0dd6432f9e7e0dba902b59597 (patch)
tree515f8f2088b674f4e71d7286746a7e7f0e9317e1 /drivers
parent54d29ad33e3483bcc7ca433a21cf294854e5154a (diff)
UIO: fix race in device_create
There is a race from when a device is created with device_create() and then the drvdata is set with a call to dev_set_drvdata() in which a sysfs file could be open, yet the drvdata will be NULL, causing all sorts of bad things to happen. This patch fixes the problem by using the new function, device_create_drvdata(). Cc: Kay Sievers <kay.sievers@vrfy.org> Cc: Hans J. Koch <hjk@linutronix.de> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/uio/uio.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/drivers/uio/uio.c b/drivers/uio/uio.c
index 55cc7b80422a..0a12e90ad416 100644
--- a/drivers/uio/uio.c
+++ b/drivers/uio/uio.c
@@ -649,15 +649,14 @@ int __uio_register_device(struct module *owner,
649 if (ret) 649 if (ret)
650 goto err_get_minor; 650 goto err_get_minor;
651 651
652 idev->dev = device_create(uio_class->class, parent, 652 idev->dev = device_create_drvdata(uio_class->class, parent,
653 MKDEV(uio_major, idev->minor), 653 MKDEV(uio_major, idev->minor), idev,
654 "uio%d", idev->minor); 654 "uio%d", idev->minor);
655 if (IS_ERR(idev->dev)) { 655 if (IS_ERR(idev->dev)) {
656 printk(KERN_ERR "UIO: device register failed\n"); 656 printk(KERN_ERR "UIO: device register failed\n");
657 ret = PTR_ERR(idev->dev); 657 ret = PTR_ERR(idev->dev);
658 goto err_device_create; 658 goto err_device_create;
659 } 659 }
660 dev_set_drvdata(idev->dev, idev);
661 660
662 ret = uio_dev_add_attributes(idev); 661 ret = uio_dev_add_attributes(idev);
663 if (ret) 662 if (ret)