Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Revert "net: wwan: mhi_wwan_mbim: Avoid -Wflex-array-member-not-at-end warning"

This reverts commit eeecf5d3a3a484cedfa3f2f87e6d51a7390ed960.

This change lead to MHI WWAN device can't connect to internet.
I found a netwrok issue with kernel 6.19-rc4, but network works
well with kernel 6.18-rc1. After checking, this commit is the
root cause.

Before appliing this serial changes on MHI WWAN network, we shall
revert this change in case of v6.19 being impacted.

Fixes: eeecf5d3a3a4 ("net: wwan: mhi_wwan_mbim: Avoid -Wflex-array-member-not-at-end warning")
Signed-off-by: Slark Xiao <slark_xiao@163.com>
Link: https://patch.msgid.link/20260120072018.29375-1-slark_xiao@163.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Slark Xiao and committed by
Jakub Kicinski
2030c435 ba1096c3

+8 -9
+8 -9
drivers/net/wwan/mhi_wwan_mbim.c
··· 78 78 79 79 struct mbim_tx_hdr { 80 80 struct usb_cdc_ncm_nth16 nth16; 81 - 82 - /* Must be last as it ends in a flexible-array member. */ 83 81 struct usb_cdc_ncm_ndp16 ndp16; 82 + struct usb_cdc_ncm_dpe16 dpe16[2]; 84 83 } __packed; 85 84 86 85 static struct mhi_mbim_link *mhi_mbim_get_link_rcu(struct mhi_mbim_context *mbim, ··· 107 108 static struct sk_buff *mbim_tx_fixup(struct sk_buff *skb, unsigned int session, 108 109 u16 tx_seq) 109 110 { 110 - DEFINE_RAW_FLEX(struct mbim_tx_hdr, mbim_hdr, ndp16.dpe16, 2); 111 111 unsigned int dgram_size = skb->len; 112 112 struct usb_cdc_ncm_nth16 *nth16; 113 113 struct usb_cdc_ncm_ndp16 *ndp16; 114 + struct mbim_tx_hdr *mbim_hdr; 114 115 115 116 /* Only one NDP is sent, containing the IP packet (no aggregation) */ 116 117 117 118 /* Ensure we have enough headroom for crafting MBIM header */ 118 - if (skb_cow_head(skb, __struct_size(mbim_hdr))) { 119 + if (skb_cow_head(skb, sizeof(struct mbim_tx_hdr))) { 119 120 dev_kfree_skb_any(skb); 120 121 return NULL; 121 122 } 122 123 123 - mbim_hdr = skb_push(skb, __struct_size(mbim_hdr)); 124 + mbim_hdr = skb_push(skb, sizeof(struct mbim_tx_hdr)); 124 125 125 126 /* Fill NTB header */ 126 127 nth16 = &mbim_hdr->nth16; ··· 133 134 /* Fill the unique NDP */ 134 135 ndp16 = &mbim_hdr->ndp16; 135 136 ndp16->dwSignature = cpu_to_le32(USB_CDC_MBIM_NDP16_IPS_SIGN | (session << 24)); 136 - ndp16->wLength = cpu_to_le16(struct_size(ndp16, dpe16, 2)); 137 + ndp16->wLength = cpu_to_le16(sizeof(struct usb_cdc_ncm_ndp16) 138 + + sizeof(struct usb_cdc_ncm_dpe16) * 2); 137 139 ndp16->wNextNdpIndex = 0; 138 140 139 141 /* Datagram follows the mbim header */ 140 - ndp16->dpe16[0].wDatagramIndex = cpu_to_le16(__struct_size(mbim_hdr)); 142 + ndp16->dpe16[0].wDatagramIndex = cpu_to_le16(sizeof(struct mbim_tx_hdr)); 141 143 ndp16->dpe16[0].wDatagramLength = cpu_to_le16(dgram_size); 142 144 143 145 /* null termination */ ··· 584 584 { 585 585 ndev->header_ops = NULL; /* No header */ 586 586 ndev->type = ARPHRD_RAWIP; 587 - ndev->needed_headroom = 588 - struct_size_t(struct mbim_tx_hdr, ndp16.dpe16, 2); 587 + ndev->needed_headroom = sizeof(struct mbim_tx_hdr); 589 588 ndev->hard_header_len = 0; 590 589 ndev->addr_len = 0; 591 590 ndev->flags = IFF_POINTOPOINT | IFF_NOARP;