Fixed SDO download via library.
authorFlorian Pose <fp@igh-essen.com>
Tue, 24 Feb 2009 10:03:53 +0000
changeset 1361 9c16b62326fa
parent 1360 afcea72f0040
child 1362 2d6e0b01c80a
Fixed SDO download via library.
master/cdev.c
--- a/master/cdev.c	Tue Feb 24 09:11:19 2009 +0000
+++ b/master/cdev.c	Tue Feb 24 10:03:53 2009 +0000
@@ -2273,6 +2273,7 @@
     ec_ioctl_sdo_request_t data;
     ec_slave_config_t *sc;
     ec_sdo_request_t *req;
+    int ret;
 
 	if (unlikely(!priv->requested))
         return -EPERM;
@@ -2280,6 +2281,11 @@
     if (copy_from_user(&data, (void __user *) arg, sizeof(data)))
         return -EFAULT;
 
+    if (!data.size) {
+        EC_ERR("Sdo download: Data size may not be zero!\n");
+        return -EINVAL;
+    }
+
     if (down_interruptible(&master->master_sem))
         return -EINTR;
 
@@ -2295,6 +2301,14 @@
 
     up(&master->master_sem);
 
+    ret = ec_sdo_request_alloc(req, data.size);
+    if (ret)
+        return ret;
+
+    if (copy_from_user(req->data, (void __user *) data.data, data.size))
+        return -EFAULT;
+
+    req->data_size = data.size;
     ecrt_sdo_request_write(req);
     return 0;
 }