]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
wifi: wil6210: Do not use embedded netdev in wil6210_priv
authorBreno Leitao <leitao@debian.org>
Fri, 3 May 2024 10:32:56 +0000 (03:32 -0700)
committerKalle Valo <quic_kvalo@quicinc.com>
Tue, 7 May 2024 10:05:24 +0000 (13:05 +0300)
Embedding net_device into structures prohibits the usage of flexible
arrays in the net_device structure. For more details, see the discussion
at [1].

Un-embed the net_device from struct wil6210_priv by converting it
into a pointer. Then use the leverage alloc_netdev_dummy() to allocate
the net_device object at wil_if_add(). The free of the device
occurs at wil_if_remove().

Link: https://lore.kernel.org/all/20240229225910.79e224cf@kernel.org/
Signed-off-by: Breno Leitao <leitao@debian.org>
Signed-off-by: Kalle Valo <quic_kvalo@quicinc.com>
Link: https://msgid.link/20240503103304.339489-1-leitao@debian.org
drivers/net/wireless/ath/wil6210/netdev.c
drivers/net/wireless/ath/wil6210/wil6210.h

index ee7d7e9c27184b425956bb8f148ea72e6a2d5c54..d5d364683c0e9e738005bf932274446a8f3904ad 100644 (file)
@@ -453,16 +453,21 @@ int wil_if_add(struct wil6210_priv *wil)
                return rc;
        }
 
-       init_dummy_netdev(&wil->napi_ndev);
+       wil->napi_ndev = alloc_netdev_dummy(0);
+       if (!wil->napi_ndev) {
+               wil_err(wil, "failed to allocate dummy netdev");
+               rc = -ENOMEM;
+               goto out_wiphy;
+       }
        if (wil->use_enhanced_dma_hw) {
-               netif_napi_add(&wil->napi_ndev, &wil->napi_rx,
+               netif_napi_add(wil->napi_ndev, &wil->napi_rx,
                               wil6210_netdev_poll_rx_edma);
-               netif_napi_add_tx(&wil->napi_ndev,
+               netif_napi_add_tx(wil->napi_ndev,
                                  &wil->napi_tx, wil6210_netdev_poll_tx_edma);
        } else {
-               netif_napi_add(&wil->napi_ndev, &wil->napi_rx,
+               netif_napi_add(wil->napi_ndev, &wil->napi_rx,
                               wil6210_netdev_poll_rx);
-               netif_napi_add_tx(&wil->napi_ndev,
+               netif_napi_add_tx(wil->napi_ndev,
                                  &wil->napi_tx, wil6210_netdev_poll_tx);
        }
 
@@ -474,10 +479,12 @@ int wil_if_add(struct wil6210_priv *wil)
        wiphy_unlock(wiphy);
        rtnl_unlock();
        if (rc < 0)
-               goto out_wiphy;
+               goto free_dummy;
 
        return 0;
 
+free_dummy:
+       free_netdev(wil->napi_ndev);
 out_wiphy:
        wiphy_unregister(wiphy);
        return rc;
@@ -554,5 +561,7 @@ void wil_if_remove(struct wil6210_priv *wil)
        netif_napi_del(&wil->napi_tx);
        netif_napi_del(&wil->napi_rx);
 
+       free_netdev(wil->napi_ndev);
+
        wiphy_unregister(wiphy);
 }
index 22a6eb3e12b7ee3d27e723484e28da829e594e34..9bd1286d2857b09774bc1faf80fb87c6a4723f8c 100644 (file)
@@ -983,7 +983,7 @@ struct wil6210_priv {
        spinlock_t eap_lock; /* guarding access to eap rekey fields */
        struct napi_struct napi_rx;
        struct napi_struct napi_tx;
-       struct net_device napi_ndev; /* dummy net_device serving all VIFs */
+       struct net_device *napi_ndev; /* dummy net_device serving all VIFs */
 
        /* DMA related */
        struct wil_ring ring_rx;