You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Since the beginning of time, struct usb_ep::maxpacket was a bitfield,
and when new 16-bit members were added, the convention was followed:
1da177e (Linus Torvalds 2005-04-16 236) unsigned maxpacket:16;
e117e74 (Robert Baldyga 2013-12-13 237) unsigned maxpacket_limit:16;
a59d6b9 (Tatyana Brokhman 2011-06-28 238) unsigned max_streams:16;
However, there is no need for this as a simple u16 can be used instead,
simplifying the struct and the resulting compiler binary output. Switch
to u16 for all three, and rearrange struct slightly to minimize holes.
No change in the final size of the struct results; the 2 byte gap is
just moved to the end, as seen with pahole:
- /* XXX 2 bytes hole, try to pack */
...
/* size: 72, cachelines: 2, members: 15 */
...
+ /* padding: 2 */
Changing this simplifies future introspection[1] of maxpacket's type during
allocations:
drivers/usb/gadget/function/f_tcm.c:330:24: error: 'typeof' applied to a bit-field
330 | fu->cmd.buf = kmalloc(fu->ep_out->maxpacket, GFP_KERNEL);
Link: https://lore.kernel.org/all/[email protected] [1]
Signed-off-by: Kees Cook <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Greg Kroah-Hartman <[email protected]>
0 commit comments