Skip to contentSkip to conversation

PATCH] firewire: add padding to some struct

PATCH JiSheng Zhang 2 participants 2 messages Jul 18, 2008

lore
Share & tools
lore
#0 lore raw
Quoted 1 line

From JiSheng Zhang <[email protected]>

struct fw_cdev_event_response and struct fw_cdev_event_iso_interrupt need padding. Otherwise, offset of the zero length array is not equal to the struct size. It may cause some strange problems under some platforms such as sparc32. This patch(against 2.6.26) should fix it.

include/linux/firewire-cdev.h +2 -0
@@ -92,6 +92,7 @@
 	__u32 type;
 	__u32 rcode;
 	__u32 length;
+	__u32 pad;
 	__u32 data[0];
 };
 
@@ -143,6 +144,7 @@
 	__u32 type;
 	__u32 cycle;
 	__u32 header_length;
+	__u32 pad;
 	__u32 header[0];
 };
 
#1 lore raw
Quoted 4 lines · JiSheng Zhang

struct fw_cdev_event_response and struct fw_cdev_event_iso_interrupt need padding. Otherwise, offset of the zero length array is not equal to the struct size. It may cause some strange problems under some platforms such as sparc32. This patch(against 2.6.26) should fix it.

The best solution to this problem would be to use

offsetof(struct fw_cdev_event_XYZ, data)

instead of sizeof(struct fw_cdev_event_XYZ) in all the places where the offset is required.

Your proposed solution to add padding...

Quoted 11 lines
include/linux/firewire-cdev.h +1 -0
@@ -92,6 +92,7 @@
 	__u32 type;
 	__u32 rcode;
 	__u32 length;
+	__u32 pad;
 	__u32 data[0];
 };
 

include/linux/firewire-cdev.h line 150

Quoted 7 lines
include/linux/firewire-cdev.h +1 -0
@@ -143,6 +144,7 @@
 	__u32 type;
 	__u32 cycle;
 	__u32 header_length;
+	__u32 pad;
 	__u32 header[0];
 };
 

...can alas not be applied because it would break ABI compatibility.

Thanks for looking into it,

Signature · 3 lines
Stefan Richter
-=====-==--- -=== =--=-
http://arcgraph.de/sr/