Skip to content

Commit 2030c43

Browse files
SlarkXiaokuba-moo
authored andcommitted
Revert "net: wwan: mhi_wwan_mbim: Avoid -Wflex-array-member-not-at-end warning"
This reverts commit eeecf5d. 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: eeecf5d ("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>
1 parent ba1096c commit 2030c43

1 file changed

Lines changed: 8 additions & 9 deletions

File tree

drivers/net/wwan/mhi_wwan_mbim.c

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,8 @@ struct mhi_mbim_context {
7878

7979
struct mbim_tx_hdr {
8080
struct usb_cdc_ncm_nth16 nth16;
81-
82-
/* Must be last as it ends in a flexible-array member. */
8381
struct usb_cdc_ncm_ndp16 ndp16;
82+
struct usb_cdc_ncm_dpe16 dpe16[2];
8483
} __packed;
8584

8685
static struct mhi_mbim_link *mhi_mbim_get_link_rcu(struct mhi_mbim_context *mbim,
@@ -108,20 +107,20 @@ static int mhi_mbim_get_link_mux_id(struct mhi_controller *cntrl)
108107
static struct sk_buff *mbim_tx_fixup(struct sk_buff *skb, unsigned int session,
109108
u16 tx_seq)
110109
{
111-
DEFINE_RAW_FLEX(struct mbim_tx_hdr, mbim_hdr, ndp16.dpe16, 2);
112110
unsigned int dgram_size = skb->len;
113111
struct usb_cdc_ncm_nth16 *nth16;
114112
struct usb_cdc_ncm_ndp16 *ndp16;
113+
struct mbim_tx_hdr *mbim_hdr;
115114

116115
/* Only one NDP is sent, containing the IP packet (no aggregation) */
117116

118117
/* Ensure we have enough headroom for crafting MBIM header */
119-
if (skb_cow_head(skb, __struct_size(mbim_hdr))) {
118+
if (skb_cow_head(skb, sizeof(struct mbim_tx_hdr))) {
120119
dev_kfree_skb_any(skb);
121120
return NULL;
122121
}
123122

124-
mbim_hdr = skb_push(skb, __struct_size(mbim_hdr));
123+
mbim_hdr = skb_push(skb, sizeof(struct mbim_tx_hdr));
125124

126125
/* Fill NTB header */
127126
nth16 = &mbim_hdr->nth16;
@@ -134,11 +133,12 @@ static struct sk_buff *mbim_tx_fixup(struct sk_buff *skb, unsigned int session,
134133
/* Fill the unique NDP */
135134
ndp16 = &mbim_hdr->ndp16;
136135
ndp16->dwSignature = cpu_to_le32(USB_CDC_MBIM_NDP16_IPS_SIGN | (session << 24));
137-
ndp16->wLength = cpu_to_le16(struct_size(ndp16, dpe16, 2));
136+
ndp16->wLength = cpu_to_le16(sizeof(struct usb_cdc_ncm_ndp16)
137+
+ sizeof(struct usb_cdc_ncm_dpe16) * 2);
138138
ndp16->wNextNdpIndex = 0;
139139

140140
/* Datagram follows the mbim header */
141-
ndp16->dpe16[0].wDatagramIndex = cpu_to_le16(__struct_size(mbim_hdr));
141+
ndp16->dpe16[0].wDatagramIndex = cpu_to_le16(sizeof(struct mbim_tx_hdr));
142142
ndp16->dpe16[0].wDatagramLength = cpu_to_le16(dgram_size);
143143

144144
/* null termination */
@@ -584,8 +584,7 @@ static void mhi_mbim_setup(struct net_device *ndev)
584584
{
585585
ndev->header_ops = NULL; /* No header */
586586
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);
589588
ndev->hard_header_len = 0;
590589
ndev->addr_len = 0;
591590
ndev->flags = IFF_POINTOPOINT | IFF_NOARP;

0 commit comments

Comments
 (0)