diff options
author | Kees Cook <kees@kernel.org> | 2024-07-09 08:49:56 -0700 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2024-07-10 13:56:22 +0200 |
commit | 2bb6b10ebe5d42c119827b57ee8123175b7ecc3d (patch) | |
tree | a98884b10b90783fb730d53b3d6cf9d03bbbdbd9 /drivers/usb | |
parent | 3eb27d3e32c78badbc4db6ae76614b5961e32291 (diff) |
usb: gadget: Use u16 types for 16-bit fields
Since the beginning of time, struct usb_ep::maxpacket was a bitfield,
and when new 16-bit members were added, the convention was followed:
1da177e4c3f41 (Linus Torvalds 2005-04-16 236) unsigned maxpacket:16;
e117e742d3106 (Robert Baldyga 2013-12-13 237) unsigned maxpacket_limit:16;
a59d6b91cbca5 (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/202407090928.6UaOAZAJ-lkp@intel.com [1]
Signed-off-by: Kees Cook <kees@kernel.org>
Link: https://lore.kernel.org/r/20240709154953.work.953-kees@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/usb')
0 files changed, 0 insertions, 0 deletions