Check for matching data size when reading Sdo entries via sysfs.
authorFlorian Pose <fp@igh-essen.com>
Tue, 03 Jun 2008 12:04:00 +0000
changeset 939 6a3b0be56498
parent 938 5b936e8e39fa
child 940 a059c79b5723
Check for matching data size when reading Sdo entries via sysfs.
master/sdo_entry.c
--- a/master/sdo_entry.c	Mon Jun 02 14:40:19 2008 +0000
+++ b/master/sdo_entry.c	Tue Jun 03 12:04:00 2008 +0000
@@ -185,6 +185,15 @@
     off_t off = 0;
     unsigned int i;
 
+    if (request->data_size != entry->bit_length) {
+        EC_ERR("Dictionary size of Sdo entry 0x%04X:%02X (%u bit) does not "
+                "match size of uploaded data (%u byte)!\n", entry->sdo->index,
+                entry->subindex, entry->bit_length, request->data_size);
+        EC_DBG("Uploaded data:\n");
+        ec_print_data(request->data, request->data_size);
+        return -EIO;
+    }
+        
     if (entry->data_type == 0x0002) { // int8
         int8_t value;
         if (entry->bit_length != 8)