]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
Revert "net: wwan: mhi_wwan_mbim: Avoid -Wflex-array-member-not-at-end warning"
authorSlark Xiao <slark_xiao@163.com>
Tue, 20 Jan 2026 07:20:18 +0000 (15:20 +0800)
committerJakub Kicinski <kuba@kernel.org>
Thu, 22 Jan 2026 03:03:37 +0000 (19:03 -0800)
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>
drivers/net/wwan/mhi_wwan_mbim.c

index 0dace12f5ad04c66ea17fea2c5ecd19557b32764..f8bc9a39bfa30747b0b67f685c262af108843793 100644 (file)
@@ -78,9 +78,8 @@ struct mhi_mbim_context {
 
 struct mbim_tx_hdr {
        struct usb_cdc_ncm_nth16 nth16;
-
-       /* Must be last as it ends in a flexible-array member. */
        struct usb_cdc_ncm_ndp16 ndp16;
+       struct usb_cdc_ncm_dpe16 dpe16[2];
 } __packed;
 
 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)
 static struct sk_buff *mbim_tx_fixup(struct sk_buff *skb, unsigned int session,
                                     u16 tx_seq)
 {
-       DEFINE_RAW_FLEX(struct mbim_tx_hdr, mbim_hdr, ndp16.dpe16, 2);
        unsigned int dgram_size = skb->len;
        struct usb_cdc_ncm_nth16 *nth16;
        struct usb_cdc_ncm_ndp16 *ndp16;
+       struct mbim_tx_hdr *mbim_hdr;
 
        /* Only one NDP is sent, containing the IP packet (no aggregation) */
 
        /* Ensure we have enough headroom for crafting MBIM header */
-       if (skb_cow_head(skb, __struct_size(mbim_hdr))) {
+       if (skb_cow_head(skb, sizeof(struct mbim_tx_hdr))) {
                dev_kfree_skb_any(skb);
                return NULL;
        }
 
-       mbim_hdr = skb_push(skb, __struct_size(mbim_hdr));
+       mbim_hdr = skb_push(skb, sizeof(struct mbim_tx_hdr));
 
        /* Fill NTB header */
        nth16 = &mbim_hdr->nth16;
@@ -134,11 +133,12 @@ static struct sk_buff *mbim_tx_fixup(struct sk_buff *skb, unsigned int session,
        /* Fill the unique NDP */
        ndp16 = &mbim_hdr->ndp16;
        ndp16->dwSignature = cpu_to_le32(USB_CDC_MBIM_NDP16_IPS_SIGN | (session << 24));
-       ndp16->wLength = cpu_to_le16(struct_size(ndp16, dpe16, 2));
+       ndp16->wLength = cpu_to_le16(sizeof(struct usb_cdc_ncm_ndp16)
+                                       + sizeof(struct usb_cdc_ncm_dpe16) * 2);
        ndp16->wNextNdpIndex = 0;
 
        /* Datagram follows the mbim header */
-       ndp16->dpe16[0].wDatagramIndex = cpu_to_le16(__struct_size(mbim_hdr));
+       ndp16->dpe16[0].wDatagramIndex = cpu_to_le16(sizeof(struct mbim_tx_hdr));
        ndp16->dpe16[0].wDatagramLength = cpu_to_le16(dgram_size);
 
        /* null termination */
@@ -584,8 +584,7 @@ static void mhi_mbim_setup(struct net_device *ndev)
 {
        ndev->header_ops = NULL;  /* No header */
        ndev->type = ARPHRD_RAWIP;
-       ndev->needed_headroom =
-                       struct_size_t(struct mbim_tx_hdr, ndp16.dpe16, 2);
+       ndev->needed_headroom = sizeof(struct mbim_tx_hdr);
        ndev->hard_header_len = 0;
        ndev->addr_len = 0;
        ndev->flags = IFF_POINTOPOINT | IFF_NOARP;