653251feff894018b5000ab874fcc39588357da2
[oweals/openwrt.git] /
1 From ba76ff25ee64d5cfc86209d1fbb3c294b2c04412 Mon Sep 17 00:00:00 2001
2 From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <rafal@milecki.pl>
3 Date: Tue, 3 Sep 2019 06:29:26 +0200
4 Subject: [PATCH 1/3] brcmfmac: move "cfg80211_ops" pointer to another struct
5 MIME-Version: 1.0
6 Content-Type: text/plain; charset=UTF-8
7 Content-Transfer-Encoding: 8bit
8
9 This moves "ops" pointer from "struct brcmf_cfg80211_info" to the
10 "struct brcmf_pub". This movement makes it possible to allocate wiphy
11 without attaching cfg80211 (brcmf_cfg80211_attach()). It's required for
12 later separation of wiphy allocation and driver initialization.
13
14 While at it fix also an unlikely memory leak in the brcmf_attach().
15
16 Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
17 Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
18 ---
19  .../net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c  | 1 -
20  .../net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.h  | 1 -
21  drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c  | 9 ++++++---
22  drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.h  | 1 +
23  4 files changed, 7 insertions(+), 5 deletions(-)
24
25 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
26 +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
27 @@ -7202,7 +7202,6 @@ void brcmf_cfg80211_detach(struct brcmf_
28         brcmf_pno_detach(cfg);
29         brcmf_btcoex_detach(cfg);
30         wiphy_unregister(cfg->wiphy);
31 -       kfree(cfg->ops);
32         wl_deinit_priv(cfg);
33         brcmf_free_wiphy(cfg->wiphy);
34         kfree(cfg);
35 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.h
36 +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.h
37 @@ -292,7 +292,6 @@ struct brcmf_cfg80211_wowl {
38   */
39  struct brcmf_cfg80211_info {
40         struct wiphy *wiphy;
41 -       struct cfg80211_ops *ops;
42         struct brcmf_cfg80211_conf *conf;
43         struct brcmf_p2p_info p2p;
44         struct brcmf_btcoex_info *btcoex;
45 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c
46 +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c
47 @@ -1245,12 +1245,15 @@ int brcmf_attach(struct device *dev, str
48                 return -ENOMEM;
49  
50         wiphy = wiphy_new(ops, sizeof(*drvr));
51 -       if (!wiphy)
52 +       if (!wiphy) {
53 +               kfree(ops);
54                 return -ENOMEM;
55 +       }
56  
57         set_wiphy_dev(wiphy, dev);
58         drvr = wiphy_priv(wiphy);
59         drvr->wiphy = wiphy;
60 +       drvr->ops = ops;
61  
62         for (i = 0; i < ARRAY_SIZE(drvr->if2bss); i++)
63                 drvr->if2bss[i] = BRCMF_BSSIDX_INVALID;
64 @@ -1283,12 +1286,10 @@ int brcmf_attach(struct device *dev, str
65                 goto fail;
66         }
67  
68 -       drvr->config->ops = ops;
69         return 0;
70  
71  fail:
72         brcmf_detach(dev);
73 -       kfree(ops);
74  
75         return ret;
76  }
77 @@ -1374,6 +1375,8 @@ void brcmf_detach(struct device *dev)
78  
79         bus_if->drvr = NULL;
80  
81 +       kfree(drvr->ops);
82 +
83         wiphy_free(drvr->wiphy);
84  }
85  
86 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.h
87 +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.h
88 @@ -97,6 +97,7 @@ struct brcmf_pub {
89         struct brcmf_bus *bus_if;
90         struct brcmf_proto *proto;
91         struct wiphy *wiphy;
92 +       struct cfg80211_ops *ops;
93         struct brcmf_cfg80211_info *config;
94  
95         /* Internal brcmf items */