git://git.onelab.eu
/
linux-2.6.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
VServer 1.9.2 (patch-2.6.8.1-vs1.9.2.diff)
[linux-2.6.git]
/
drivers
/
i2c
/
i2c-dev.c
diff --git
a/drivers/i2c/i2c-dev.c
b/drivers/i2c/i2c-dev.c
index
a0a4aa1
..
af17f14
100644
(file)
--- a/
drivers/i2c/i2c-dev.c
+++ b/
drivers/i2c/i2c-dev.c
@@
-181,7
+181,7
@@
int i2cdev_ioctl (struct inode *inode, struct file *file, unsigned int cmd,
struct i2c_smbus_ioctl_data data_arg;
union i2c_smbus_data temp;
struct i2c_msg *rdwr_pa;
struct i2c_smbus_ioctl_data data_arg;
union i2c_smbus_data temp;
struct i2c_msg *rdwr_pa;
- u8 **data_ptrs;
+ u8
__user
**data_ptrs;
int i,datasize,res;
unsigned long funcs;
int i,datasize,res;
unsigned long funcs;
@@
-238,8
+238,7
@@
int i2cdev_ioctl (struct inode *inode, struct file *file, unsigned int cmd,
return -EFAULT;
}
return -EFAULT;
}
- data_ptrs = (u8 **) kmalloc(rdwr_arg.nmsgs * sizeof(u8 *),
- GFP_KERNEL);
+ data_ptrs = kmalloc(rdwr_arg.nmsgs * sizeof(u8 __user *), GFP_KERNEL);
if (data_ptrs == NULL) {
kfree(rdwr_pa);
return -ENOMEM;
if (data_ptrs == NULL) {
kfree(rdwr_pa);
return -ENOMEM;
@@
-252,7
+251,7
@@
int i2cdev_ioctl (struct inode *inode, struct file *file, unsigned int cmd,
res = -EINVAL;
break;
}
res = -EINVAL;
break;
}
- data_ptrs[i] = rdwr_pa[i].buf;
+ data_ptrs[i] =
(u8 __user *)
rdwr_pa[i].buf;
rdwr_pa[i].buf = kmalloc(rdwr_pa[i].len, GFP_KERNEL);
if(rdwr_pa[i].buf == NULL) {
res = -ENOMEM;
rdwr_pa[i].buf = kmalloc(rdwr_pa[i].len, GFP_KERNEL);
if(rdwr_pa[i].buf == NULL) {
res = -ENOMEM;
@@
-519,20
+518,29
@@
static int __init i2c_dev_init(void)
printk(KERN_INFO "i2c /dev entries driver\n");
printk(KERN_INFO "i2c /dev entries driver\n");
- if (register_chrdev(I2C_MAJOR,"i2c",&i2cdev_fops)) {
- printk(KERN_ERR "i2c-dev.o: unable to get major %d for i2c bus\n",
- I2C_MAJOR);
- return -EIO;
- }
+ res = register_chrdev(I2C_MAJOR, "i2c", &i2cdev_fops);
+ if (res)
+ goto out;
+
+ res = class_register(&i2c_dev_class);
+ if (res)
+ goto out_unreg_chrdev;
+
+ res = i2c_add_driver(&i2cdev_driver);
+ if (res)
+ goto out_unreg_class;
+
devfs_mk_dir("i2c");
devfs_mk_dir("i2c");
- class_register(&i2c_dev_class);
- if ((res = i2c_add_driver(&i2cdev_driver))) {
- printk(KERN_ERR "i2c-dev.o: Driver registration failed, module not inserted.\n");
- devfs_remove("i2c");
- unregister_chrdev(I2C_MAJOR,"i2c");
- return res;
- }
+
return 0;
return 0;
+
+out_unreg_class:
+ class_unregister(&i2c_dev_class);
+out_unreg_chrdev:
+ unregister_chrdev(I2C_MAJOR, "i2c");
+out:
+ printk(KERN_ERR "%s: Driver Initialisation failed", __FILE__);
+ return res;
}
static void __exit i2c_dev_exit(void)
}
static void __exit i2c_dev_exit(void)