mirror_ubuntu-kernels/include/linux/usb
Kees Cook 2bb6b10ebe 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:

1da177e4c3 (Linus Torvalds   2005-04-16 236) unsigned maxpacket:16;
e117e742d3 (Robert Baldyga   2013-12-13 237) unsigned maxpacket_limit:16;
a59d6b91cb (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>
2024-07-10 13:56:22 +02:00
..
audio-v2.h usb: audio-v2: Correct comments for struct uac_clock_selector_descriptor 2024-01-27 16:53:38 -08:00
audio-v3.h
audio.h
c67x00.h
ccid.h
cdc_ncm.h
cdc-wdm.h
cdc.h
ch9.h
chipidea.h usb: chipidea: add CI_HDRC_FORCE_VBUS_ACTIVE_ALWAYS flag 2023-10-21 12:45:45 +02:00
composite.h usb: gadget: clarify usage of USB_GADGET_DELAYED_STATUS 2023-10-02 16:43:04 +02:00
ehci_def.h
ehci_pdriver.h
ehci-dbgp.h
ezusb.h
functionfs.h
g_hid.h
gadget_configfs.h
gadget.h usb: gadget: Use u16 types for 16-bit fields 2024-07-10 13:56:22 +02:00
hcd.h workqueue: BH workqueue conversions for v6.9 2024-03-11 13:05:19 -07:00
input.h
iowarrior.h
irda.h
isp116x.h
isp1301.h
isp1362.h
ljca.h usb: Add support for Intel LJCA device 2023-10-11 11:33:37 +02:00
m66592.h
midi-v2.h
musb-ux500.h
musb.h
net2280.h
of.h usb: core: Set connect_type of ports based on DT node 2024-03-05 13:28:46 +00:00
ohci_pdriver.h
onboard_dev.h usb: misc: onboard_hub: rename to onboard_dev 2024-03-27 07:57:16 +01:00
otg-fsm.h
otg.h
pd_ado.h
pd_bdo.h
pd_ext_sdb.h
pd_vdo.h usb: typec: pd: no opencoding of FIELD_GET 2024-03-05 13:09:59 +00:00
pd.h usb: typec: tcpm: add control message support to sop' 2024-01-27 17:38:25 -08:00
phy_companion.h
phy.h Revert "usb: phy: add usb phy notify port status API" 2023-11-06 14:47:36 +01:00
quirks.h usb: new quirk to reduce the SET_ADDRESS request timeout 2023-11-23 12:32:44 +00:00
r8a66597.h
r8152.h r8152: add vendor/device ID pair for ASUS USB-C2500 2023-12-06 10:38:38 +01:00
renesas_usbhs.h usb: renesas_usbhs: Remove renesas_usbhs_get_info() wrapper 2024-04-18 16:47:49 +02:00
rndis_host.h
role.h
rzv2m_usb3drd.h
serial.h
sl811.h
storage.h
tcpci.h usb: typec: tcpci: add support to set connector orientation 2024-07-03 16:05:38 +02:00
tcpm.h usb: typec: tcpm: add support to set tcpc connector orientatition 2024-03-05 13:29:30 +00:00
tegra_usb_phy.h usb: phy: tegra: Replace of_gpio.h by proper one 2024-05-10 10:36:31 +01:00
typec_altmode.h usb: typec: altmodes: add svdm version info for typec cables 2024-01-27 17:38:25 -08:00
typec_dp.h usb: typec: pd: no opencoding of FIELD_GET 2024-03-05 13:09:59 +00:00
typec_mux.h
typec_retimer.h
typec_tbt.h USB: typec: no opencoding FIELD_GET 2024-03-02 20:20:41 +01:00
typec.h usb: typec: Update sysfs when setting ops 2024-06-04 15:44:27 +02:00
uas.h
ulpi.h
usb338x.h
usb_phy_generic.h
usbnet.h
uvc.h
webusb.h
xhci-dbgp.h